Rename table module to schema module

This commit is contained in:
Marty Oehme 2021-08-29 09:46:55 +02:00
parent 3184e5d6fa
commit c41a492b07
Signed by: Marty
GPG key ID: B7538B8F50A1C800
2 changed files with 12 additions and 2 deletions

View file

@ -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)

View file

@ -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