Remove the db compatibility shim#453
Draft
somethingnew2-0 wants to merge 1 commit into
Draft
Conversation
Drop the Flask-SQLAlchemy emulation surface that was preserved through the FastAPI + Pydantic v2 migration (#425) — `db.Model` / `db.Column` / `db.relationship` / `db.func` / `db.or_` / `db.and_` / `db.not_` and the `Model.query` descriptor with `first_or_404` / `paginate` helpers. `db.session` survives as a thin session/engine facade in `api/extensions.py` so `db.session.query(Model).filter(...)` keeps working through operations and routers. Models move to direct `from sqlalchemy import ...` with `Mapped[T]` annotations on `mapped_column`. `Model.query.X` chains are swapped 1:1 to `db.session.query(Model).X` across operations, routers, syncer, integrity, and tests. Closes POST_MIGRATION_TODO.md item #1. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
db.Model/db.Column/db.relationship/db.func/db.or_/db.and_/db.not_, theModel.querydescriptor withfirst_or_404/get_or_404/paginate) inapi/extensions.py.db.sessionsurvives as a slim session/engine facade sodb.session.query(Model).filter(...)keeps working.api/models/to directfrom sqlalchemy import ...withMapped[T]annotations onmapped_column— idiomatic SQLAlchemy 2.0.Model.query.Xtodb.session.query(Model).Xacross 28 operation files, the 9 routers,api/syncer.py,api/integrity.py,api/auth/permissions.py, and the test suite.Follow-up to #425 — the migration kept the shim alive so the diff could focus on the Flask→FastAPI plumbing.
Test plan
pytest tests/— 426 passed locally (no flakes/skips related to this change)alembic upgrade headagainst a fresh SQLite DB applies cleanly — no schema drift from theColumn→mapped_columnmovepython -c "from api.app import create_app; create_app(testing=True)"returns clean🤖 Generated with Claude Code