diff options
-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;") |