fix: Migration e7f1a9c3b214 auch auf SQLite lauffähig (A14-T1 Fixrunde)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
"""Alembic-Revision e7f1a9c3b214 (A14) muss auch auf SQLite hoch/runter/hoch laufen."""
|
||||
from pathlib import Path
|
||||
|
||||
from alembic import command
|
||||
from alembic.config import Config
|
||||
from sqlalchemy import create_engine, inspect
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
|
||||
def test_migration_a14_sqlite_up_down_up(tmp_path, monkeypatch):
|
||||
url = f"sqlite:///{tmp_path / 'mig.db'}"
|
||||
monkeypatch.setenv("FB_DATABASE_URL", url)
|
||||
from app.config import get_settings
|
||||
get_settings.cache_clear()
|
||||
try:
|
||||
cfg = Config(str(ROOT / "alembic.ini"))
|
||||
cfg.set_main_option("script_location", str(ROOT / "alembic"))
|
||||
engine = create_engine(url)
|
||||
|
||||
def state():
|
||||
insp = inspect(engine)
|
||||
return ("scenario_recurring_items" in insp.get_table_names(),
|
||||
"category_id" in {c["name"] for c in
|
||||
insp.get_columns("scenario_planned_items")})
|
||||
|
||||
command.upgrade(cfg, "head")
|
||||
assert state() == (True, True)
|
||||
command.downgrade(cfg, "d5e8b3c7a410")
|
||||
assert state() == (False, False)
|
||||
command.upgrade(cfg, "head")
|
||||
assert state() == (True, True)
|
||||
engine.dispose()
|
||||
finally:
|
||||
get_settings.cache_clear()
|
||||
Reference in New Issue
Block a user