Update the setup_db code to create version-1 database

Including the single state table entry with the version 1 tag

Change-Id: I00438613f735e8191725e4a47e32d77baff39891
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 @@
             "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;")