41 lines
918 B
Python
41 lines
918 B
Python
"""Drop legacy lab tables: tab staging, norm dump, calc errors in DB.
|
|
|
|
Revision ID: lab_drop_legacy_artifacts
|
|
Revises: lab_drop_sync_columns
|
|
Create Date: 2026-06-09
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision = "lab_drop_legacy_artifacts"
|
|
down_revision = "lab_drop_sync_columns"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
_LEGACY_TABLES = (
|
|
"lab_tab_ration_line",
|
|
"lab_tab_ration_project",
|
|
"lab_norm_entry",
|
|
"lab_ration_calc_error",
|
|
)
|
|
|
|
|
|
def upgrade(**kw) -> None:
|
|
if kw.get("tag") == "reports":
|
|
return
|
|
bind = op.get_bind()
|
|
insp = sa.inspect(bind)
|
|
if bind.dialect.name == "sqlite":
|
|
op.execute(sa.text("PRAGMA foreign_keys=OFF"))
|
|
for table in _LEGACY_TABLES:
|
|
if table in insp.get_table_names():
|
|
op.drop_table(table)
|
|
|
|
|
|
def downgrade(**kw) -> None:
|
|
if kw.get("tag") == "reports":
|
|
return
|