diff --git a/backend/aci/migrate.py b/backend/aci/migrate.py new file mode 100644 index 0000000..8187b31 --- /dev/null +++ b/backend/aci/migrate.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 +import sqlite3 + +def run_migrations(): + conn = sqlite3.connect('./checkin.db') + db = conn.cursor() + + try: + db.execute("CREATE TABLE IF NOT EXISTS code_results (date text, time text, space text, activity text, code text, result boolean)") + finally: + db.close() + conn.close() diff --git a/backend/app.py b/backend/app.py index 599ea54..050a1ef 100644 --- a/backend/app.py +++ b/backend/app.py @@ -10,6 +10,7 @@ from fastapi.middleware.cors import CORSMiddleware import uvicorn from aci.db import get_db +from aci.migrate import run_migrations from aci.models import CodeSubmission from aci import utils @@ -59,4 +60,5 @@ def current_codes(db: sqlite3.Cursor=Depends(get_db)): } if __name__ == '__main__': + run_migrations() uvicorn.run(app) diff --git a/backend/migrate.py b/backend/migrate.py deleted file mode 100644 index bb9da73..0000000 --- a/backend/migrate.py +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env python3 -import sqlite3 - -conn = sqlite3.connect('./checkin.db') -db = conn.cursor() - -try: - db.execute("CREATE TABLE IF NOT EXISTS code_results (date text, time text, space text, activity text, code text, result boolean)") -finally: - db.close() - conn.close()