Rename table module to schema module
This commit is contained in:
parent
3184e5d6fa
commit
c41a492b07
2 changed files with 12 additions and 2 deletions
|
@ -1,10 +1,10 @@
|
||||||
import loop.tables as tables
|
import loop.schema as schema
|
||||||
import loop.habits as habits
|
import loop.habits as habits
|
||||||
import loop.repetitions as rep
|
import loop.repetitions as rep
|
||||||
|
|
||||||
|
|
||||||
def migrate(trackers, events):
|
def migrate(trackers, events):
|
||||||
db = tables.migrate("output.db")
|
db = schema.migrate("output.db")
|
||||||
if trackers is not None:
|
if trackers is not None:
|
||||||
|
|
||||||
habitlist = habits.migrate(db, trackers)
|
habitlist = habits.migrate(db, trackers)
|
||||||
|
|
|
@ -55,7 +55,17 @@ def create_tables(db):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def create_constraints(db):
|
||||||
|
c = db.cursor()
|
||||||
|
c.execute(
|
||||||
|
""" CREATE UNIQUE INDEX IF NOT EXISTS idx_repetitions_habit_timestamp
|
||||||
|
on Repetitions( habit, timestamp);
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def migrate(name):
|
def migrate(name):
|
||||||
db = create_database(name)
|
db = create_database(name)
|
||||||
create_tables(db)
|
create_tables(db)
|
||||||
|
create_constraints(db)
|
||||||
return db
|
return db
|
Loading…
Reference in a new issue