From 013aa823964fe64198bc9ed1bde2ac6f5da1b4ad Mon Sep 17 00:00:00 2001 From: Daniel Reeves Date: Tue, 19 Nov 2024 19:07:43 -0500 Subject: [PATCH] fix --- alembic/versions/rev001.py | 14 +++----------- alembic/versions/rev002.py | 13 ++++++++++++- app/data/database.py | 4 ---- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/alembic/versions/rev001.py b/alembic/versions/rev001.py index a8b5243..6304a82 100644 --- a/alembic/versions/rev001.py +++ b/alembic/versions/rev001.py @@ -9,6 +9,8 @@ """ +import os + import sqlalchemy as sa from sqlalchemy import schema @@ -52,7 +54,7 @@ def upgrade(): sa.PrimaryKeyConstraint("boathouse"), ) - with open(f"{QUERIES_DIR}/override_event_triggers_v1.sql", "r") as f: + with open(os.path.join(QUERIES_DIR, "override_event_triggers_v1.sql"), "r") as f: sql = sa.text(f.read()) conn.execute(sql) @@ -71,16 +73,6 @@ def upgrade(): sa.Column("reason", sa.TEXT(), nullable=True), ) - with open(f"{QUERIES_DIR}/define_reach.sql", "r") as f: - sql = sa.text(f.read()) - conn.execute(sql) - with open(f"{QUERIES_DIR}/define_boathouse.sql", "r") as f: - sql = sa.text(f.read()) - conn.execute(sql) - with open(f"{QUERIES_DIR}/define_default_options.sql", "r") as f: - sql = sa.text(f.read()) - conn.execute(sql) - def downgrade(): op.drop_table("live_website_options") diff --git a/alembic/versions/rev002.py b/alembic/versions/rev002.py index 74501f6..3718675 100644 --- a/alembic/versions/rev002.py +++ b/alembic/versions/rev002.py @@ -7,6 +7,8 @@ """ +import os + import sqlalchemy as sa from sqlalchemy.engine.reflection import Inspector @@ -77,7 +79,16 @@ def upgrade(): op.create_unique_constraint(None, "boathouses", ["name"]) op.create_foreign_key(None, "boathouses", "reach", ["reach_id"], ["id"]) op.rename_table("boathouses", "boathouse") - with open(QUERIES_DIR + "/override_event_triggers_v2.sql", "r") as f: + with open(os.path.join(QUERIES_DIR, "override_event_triggers_v2.sql"), "r") as f: + sql = sa.text(f.read()) + conn.execute(sql) + with open(os.path.join(QUERIES_DIR, "define_reach.sql"), "r") as f: + sql = sa.text(f.read()) + conn.execute(sql) + with open(os.path.join(QUERIES_DIR, "define_boathouse.sql"), "r") as f: + sql = sa.text(f.read()) + conn.execute(sql) + with open(os.path.join(QUERIES_DIR, "define_default_options.sql"), "r") as f: sql = sa.text(f.read()) conn.execute(sql) diff --git a/app/data/database.py b/app/data/database.py index d48ee83..9d424f8 100644 --- a/app/data/database.py +++ b/app/data/database.py @@ -69,10 +69,6 @@ def init_db(): alembic.config.main(["upgrade", "head"]) - execute_sql_from_file("define_reach.sql") - execute_sql_from_file("define_boathouse.sql") - execute_sql_from_file("define_default_options.sql") - # Now update the database from app.data.processing.core import update_db