fix(tests): drop_all before create_all to clear stale PostgreSQL enums

If a previous test run was interrupted before teardown, PostgreSQL enum
types persist with stale values, causing create_all to fail. Adding
drop_all first ensures a clean slate.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-21 11:29:26 +01:00
parent 7ff271efba
commit 4946ebb54c
2 changed files with 51 additions and 0 deletions

View File

@@ -24,6 +24,7 @@ async def engine():
"""Create the test engine and schema once for the entire session."""
eng = create_async_engine(TEST_DATABASE_URL, echo=False)
async with eng.begin() as conn:
await conn.run_sync(Base.metadata.drop_all)
await conn.run_sync(Base.metadata.create_all)
yield eng
async with eng.begin() as conn: