Fix index creation in db

This commit is contained in:
webmaster@phyks.me 2015-11-12 23:23:41 +01:00
parent ec339b9a76
commit ed329190be

View File

@ -33,10 +33,11 @@ def db_init():
"updated INTEGER, " + "updated INTEGER, " +
"FOREIGN KEY(station_id) REFERENCES stations(id) ON DELETE CASCADE)") "FOREIGN KEY(station_id) REFERENCES stations(id) ON DELETE CASCADE)")
c.execute("CREATE TABLE IF NOT EXISTS stationsevents(" + c.execute("CREATE TABLE IF NOT EXISTS stationsevents(" +
"station_id INTEGER PRIMARY KEY, " + "station_id INTEGER, " +
"timestamp INTEGER, " + "timestamp INTEGER, " +
"event TEXT, " + "event TEXT, " +
"FOREIGN KEY(station_id) REFERENCES stations(id) ON DELETE CASCADE)") "FOREIGN KEY(station_id) REFERENCES stations(id) ON DELETE CASCADE)")
c.execute("CREATE INDEX IF NOT EXISTS stationsevents_station_id ON stationsevents (station_id)");
conn.commit() conn.commit()
return conn return conn