Warnings fixed: - datetime.utcnow() → datetime.now(UTC) across 48+ files (src/ + tests/) - datetime.utcnow (callback ref) → lambda: datetime.now(UTC) in model fields (18 files) - Pydantic class Config → model_config = ConfigDict(...) (16 files) - Pydantic .dict() → .model_dump() (8 files) - ConfigDict(allow_population_by_field_name=True) → validate_by_name=True - SQLAlchemy declarative_base() import path updated - FastAPI on_event → lifespan context manager (app.py) - Import sorting (ruff I001) auto-fixed across all files - Fixed broken re-export chains that ruff F401 cleanup broke: _validate_bcp47: service.py now imports from dictionary_validation directly job_to_response: _job_routes.py and test imports from service_utils directly fetch_datasource_metadata: restored re-export in service.py - Added missing TranslateJobService import in _job_routes.py (was deleted by F401) - Added ConfigDict(protected_namespaces=()) for DashboardDatasetItem schema field - pytest.ini: replaced deprecated importmode with asyncio_mode All 440 tests pass with zero deprecation warnings.
53 lines
1.7 KiB
Python
53 lines
1.7 KiB
Python
"""cascade ondelete for all remaining environments FK references
|
|
|
|
Revision ID: f0e9d8c7b6a5
|
|
Revises: a5b6c7d8e9f0, e5f4d3c2b1a
|
|
Create Date: 2026-05-21 19:00:00.000000
|
|
|
|
"""
|
|
from collections.abc import Sequence
|
|
|
|
from alembic import op
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = 'f0e9d8c7b6a5'
|
|
down_revision: str | Sequence[str] | None = ('a5b6c7d8e9f0', 'e5f4d3c2b1a')
|
|
branch_labels: str | Sequence[str] | None = None
|
|
depends_on: str | Sequence[str] | None = None
|
|
|
|
FK_DEFS = [
|
|
('resource_mappings', 'resource_mappings_environment_id_fkey', 'environment_id'),
|
|
('database_mappings', 'database_mappings_source_env_id_fkey', 'source_env_id'),
|
|
('database_mappings', 'database_mappings_target_env_id_fkey', 'target_env_id'),
|
|
('migration_jobs', 'migration_jobs_source_env_id_fkey', 'source_env_id'),
|
|
('migration_jobs', 'migration_jobs_target_env_id_fkey', 'target_env_id'),
|
|
('dataset_review_sessions', 'dataset_review_sessions_environment_id_fkey', 'environment_id'),
|
|
]
|
|
|
|
|
|
def upgrade() -> None:
|
|
"""Upgrade schema."""
|
|
for table, constraint_name, column in FK_DEFS:
|
|
op.drop_constraint(constraint_name, table, type_='foreignkey')
|
|
op.create_foreign_key(
|
|
constraint_name,
|
|
table,
|
|
'environments',
|
|
[column],
|
|
['id'],
|
|
ondelete='CASCADE',
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
"""Downgrade schema."""
|
|
for table, constraint_name, column in reversed(FK_DEFS):
|
|
op.drop_constraint(constraint_name, table, type_='foreignkey')
|
|
op.create_foreign_key(
|
|
constraint_name,
|
|
table,
|
|
'environments',
|
|
[column],
|
|
['id'],
|
|
)
|