Skip to content

Commit

Permalink
Explicitly commit schema deletion on init_db.delete
Browse files Browse the repository at this point in the history
engine.connect() used in delete() and SQLA's create_all in create() might execute in separate
transactions.

Explicitly commit the schema deletion in the first step so it's visible to the rest of the init_db script.
  • Loading branch information
marcospri committed Sep 5, 2024
1 parent ffc2af3 commit 6ac56ad
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lms/scripts/init_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def delete(engine: Engine) -> None:
# For example, this will delete tables created by migrations in other branches, not only the ones SQLAlchemy know about in the current code base.
connection.execute(text("DROP SCHEMA PUBLIC CASCADE;"))
connection.execute(text("CREATE SCHEMA PUBLIC;"))
connection.execute(text("COMMIT;"))

try:
from lms.db import post_delete # noqa: PLC0415
Expand Down

0 comments on commit 6ac56ad

Please sign in to comment.