fix: add missing schema columns and Alembic model imports
- Added 4 missing columns to _ensure_translation_jobs_columns() inline migration: target_language_column, target_source_column, target_source_language_column, disable_reasoning — these were in the SQLAlchemy model but had no Alembic migration or _ensure_*() coverage - Added missing api_key, assistant, clean_release model imports to alembic/env.py so autogenerate can see all tables
This commit is contained in:
@@ -30,7 +30,10 @@ from src.models.mapping import Base
|
||||
|
||||
# Import ALL model modules so their tables are registered in Base.metadata
|
||||
from src.models import ( # noqa: F401
|
||||
api_key,
|
||||
assistant,
|
||||
auth,
|
||||
clean_release,
|
||||
dashboard,
|
||||
dataset_review_pkg,
|
||||
filter_state,
|
||||
|
||||
@@ -527,6 +527,71 @@ def _ensure_translation_jobs_columns(bind_engine):
|
||||
extra={"error": str(migration_error)},
|
||||
)
|
||||
|
||||
# Columns added to model AFTER initial Alembic migration — no Alembic migration exists
|
||||
if "target_language_column" not in existing_columns:
|
||||
try:
|
||||
with bind_engine.begin() as connection:
|
||||
connection.execute(
|
||||
text(
|
||||
"ALTER TABLE translation_jobs "
|
||||
"ADD COLUMN target_language_column VARCHAR"
|
||||
)
|
||||
)
|
||||
logger.reflect("Added target_language_column to translation_jobs")
|
||||
except Exception as migration_error:
|
||||
logger.explore(
|
||||
"Failed to add target_language_column to translation_jobs",
|
||||
extra={"error": str(migration_error)},
|
||||
)
|
||||
|
||||
if "target_source_column" not in existing_columns:
|
||||
try:
|
||||
with bind_engine.begin() as connection:
|
||||
connection.execute(
|
||||
text(
|
||||
"ALTER TABLE translation_jobs "
|
||||
"ADD COLUMN target_source_column VARCHAR"
|
||||
)
|
||||
)
|
||||
logger.reflect("Added target_source_column to translation_jobs")
|
||||
except Exception as migration_error:
|
||||
logger.explore(
|
||||
"Failed to add target_source_column to translation_jobs",
|
||||
extra={"error": str(migration_error)},
|
||||
)
|
||||
|
||||
if "target_source_language_column" not in existing_columns:
|
||||
try:
|
||||
with bind_engine.begin() as connection:
|
||||
connection.execute(
|
||||
text(
|
||||
"ALTER TABLE translation_jobs "
|
||||
"ADD COLUMN target_source_language_column VARCHAR"
|
||||
)
|
||||
)
|
||||
logger.reflect("Added target_source_language_column to translation_jobs")
|
||||
except Exception as migration_error:
|
||||
logger.explore(
|
||||
"Failed to add target_source_language_column to translation_jobs",
|
||||
extra={"error": str(migration_error)},
|
||||
)
|
||||
|
||||
if "disable_reasoning" not in existing_columns:
|
||||
try:
|
||||
with bind_engine.begin() as connection:
|
||||
connection.execute(
|
||||
text(
|
||||
"ALTER TABLE translation_jobs "
|
||||
"ADD COLUMN disable_reasoning BOOLEAN NOT NULL DEFAULT FALSE"
|
||||
)
|
||||
)
|
||||
logger.reflect("Added disable_reasoning column to translation_jobs")
|
||||
except Exception as migration_error:
|
||||
logger.explore(
|
||||
"Failed to add disable_reasoning to translation_jobs",
|
||||
extra={"error": str(migration_error)},
|
||||
)
|
||||
|
||||
|
||||
def _ensure_dataset_review_session_columns(bind_engine):
|
||||
with belief_scope("_ensure_dataset_review_session_columns"):
|
||||
|
||||
Reference in New Issue
Block a user