diff options
author | Steve McIntyre <steve.mcintyre@linaro.org> | 2018-01-31 17:16:53 +0000 |
---|---|---|
committer | Steve McIntyre <steve.mcintyre@linaro.org> | 2018-01-31 17:16:53 +0000 |
commit | 719e377b837d00867ee996cc5eb0ac832e2e4f7e (patch) | |
tree | b1ba59704142cefd1ed3928f6209eff9de3d36b6 | |
parent | 6794088d9f33e585000539f3bbff81ff6337b035 (diff) |
Update the setup_db code to create version-1 database
Including the single state table entry with the version 1 tag
Change-Id: I00438613f735e8191725e4a47e32d77baff39891
-rwxr-xr-x | db/setup_db.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/db/setup_db.py b/db/setup_db.py index 37ed7dc..84fe622 100755 --- a/db/setup_db.py +++ b/db/setup_db.py @@ -1,6 +1,6 @@ #! /usr/bin/python -# Copyright 2014-2015 Linaro Limited +# Copyright 2014-2018 Linaro Limited # Authors: Dave Pigott <dave.pigot@linaro.org>, # Steve McIntyre <steve.mcintyre@linaro.org> # @@ -22,8 +22,9 @@ # First of all, create the vland user # Next - create the vland database -# Create the switch, port, vlan and trunk tables +# Create the switch, port, vlan, trunk and state tables +import datetime from psycopg2 import connect conn = connect(database="postgres", user="postgres", password="postgres") @@ -45,6 +46,7 @@ cur.execute("CREATE TABLE vlan (vlan_id SERIAL, name VARCHAR(32)," "tag INTEGER, is_base_vlan BOOLEAN, creation_time TIMESTAMP)") cur.execute("CREATE TABLE trunk (trunk_id SERIAL," "creation_time TIMESTAMP)") -cur.execute("CREATE TABLE state (last_modified TIMESTAMP)") +cur.execute("CREATE TABLE state (last_modified TIMESTAMP, schema_version INTEGER)") +cur.execute("INSERT INTO state (last_modified, schema_version) VALUES (%s, %s)" % (datetime.datetime.now(), "1")) cur.execute("COMMIT;") |