Files
ss-tools/backend/alembic/versions/f1a2b3c4d5e6_drop_dict_dialect_columns.py
busya 1e6ec34c2b feat(backend): drop dictionary dialect columns, add allowed_languages
- Removes source_dialect and target_dialect from TerminologyDictionary model,
  schemas, routes, helper serialization, and all tests
- Adds allowed_languages config field (BCP-47 language codes) to GlobalSettings
  with validation, consolidated settings response, and API endpoint
- Adds alembic migration f1a2b3c4d5e6 to drop the two columns
2026-06-03 11:48:03 +03:00

45 lines
1.4 KiB
Python

"""drop source_dialect/target_dialect from terminology_dictionaries
Revision ID: f1a2b3c4d5e6
Revises: dabc97097e0e
Create Date: 2026-06-02 12:00:00.000000
"""
from collections.abc import Sequence
from alembic import op
from sqlalchemy import inspect
# revision identifiers, used by Alembic.
revision: str = 'f1a2b3c4d5e6'
down_revision: str | Sequence[str] | None = 'dabc97097e0e'
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
def _column_exists(table_name: str, column_name: str) -> bool:
conn = op.get_bind()
inspector = inspect(conn)
columns = [c["name"] for c in inspector.get_columns(table_name)]
return column_name in columns
def upgrade() -> None:
"""Drop source_dialect and target_dialect from terminology_dictionaries."""
if not _column_exists("terminology_dictionaries", "source_dialect"):
return
op.drop_column("terminology_dictionaries", "source_dialect")
op.drop_column("terminology_dictionaries", "target_dialect")
def downgrade() -> None:
"""Re-add source_dialect and target_dialect to terminology_dictionaries."""
import sqlalchemy as sa
op.add_column("terminology_dictionaries", sa.Column(
"source_dialect", sa.String(), nullable=False, server_default="",
))
op.add_column("terminology_dictionaries", sa.Column(
"target_dialect", sa.String(), nullable=False, server_default="",
))