Skip to content

Remove the db compatibility shim#453

Draft
somethingnew2-0 wants to merge 1 commit into
mainfrom
pcollins/remove-db-shim
Draft

Remove the db compatibility shim#453
somethingnew2-0 wants to merge 1 commit into
mainfrom
pcollins/remove-db-shim

Conversation

@somethingnew2-0
Copy link
Copy Markdown
Collaborator

Summary

  • Drop the Flask-SQLAlchemy emulation surface (db.Model / db.Column / db.relationship / db.func / db.or_ / db.and_ / db.not_, the Model.query descriptor with first_or_404 / get_or_404 / paginate) in api/extensions.py. db.session survives as a slim session/engine facade so db.session.query(Model).filter(...) keeps working.
  • Move all six model files in api/models/ to direct from sqlalchemy import ... with Mapped[T] annotations on mapped_column — idiomatic SQLAlchemy 2.0.
  • Mechanically swap Model.query.X to db.session.query(Model).X across 28 operation files, the 9 routers, api/syncer.py, api/integrity.py, api/auth/permissions.py, and the test suite.
  • Tick item Bump the npm-major group with 9 updates #1 off POST_MIGRATION_TODO.md.

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 head against a fresh SQLite DB applies cleanly — no schema drift from the Columnmapped_column move
  • App boots: python -c "from api.app import create_app; create_app(testing=True)" returns clean
  • CI green

🤖 Generated with Claude Code

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>
@somethingnew2-0 somethingnew2-0 marked this pull request as draft May 26, 2026 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant