Fix SQLAlchemy 2.x compatibility in Alembic migrations (sa.true_ → sa.True_) #79

Closed
opened 2026-03-06 19:12:07 +00:00 by forgejo_admin · 0 comments
Contributor

Plan

plan-2026-02-26-tf-modularize-postgres -- Phase 3, Part B step 5 ("Fix SQLite-isms in migration files")

Repo

forgejo_admin/pal-e-docs

User Story

As a platform operator
I want Alembic migrations to run cleanly against Postgres
So that the SQLite-to-Postgres migration can proceed

Context

Phase 3 of the Postgres plan requires running alembic upgrade head against a fresh Postgres database. Two migration files use sa.true_() which was deprecated/removed in SQLAlchemy 2.x — the correct API is sa.True_() (capital T). This causes AttributeError: module 'sqlalchemy' has no attribute 'true_' when running migrations against Postgres.

The first two migrations (initial schema, repos table) ran successfully. The users table migration fails.

File Targets

Files the agent should modify:

  • alembic/versions/b2c3d4e5f6a7_add_users_table.py line 26 — sa.true_()sa.True_()
  • alembic/versions/c3d4e5f6a7b8_add_project_is_public_and_page_note_fk.py line 23 — sa.true_()sa.True_()

Files the agent should NOT touch:

  • All other migration files — only these two have the issue

Acceptance Criteria

  • sa.true_() replaced with sa.True_() in both files
  • No other changes to migration files

Test Expectations

  • alembic upgrade head completes without errors against Postgres
  • Run: port-forward to Postgres first, then PALDOCS_DATABASE_URL=postgresql://paledocs:PfyJMdX4mPJF8eyYS38l@127.0.0.1:5432/paledocs .venv/bin/alembic upgrade head
  • Note: Postgres DB may have partial schema from failed run (first 2 migrations applied). alembic downgrade base first if needed, or drop and recreate.

Constraints

  • Two-character fix. Keep it minimal.
  • SQLAlchemy 2.x API: sa.True_() and sa.False_() are the correct forms

Checklist

  • PR opened
  • Tests pass
  • No unrelated changes
  • plan-2026-02-26-tf-modularize-postgres Phase 3 — this blocks data migration
  • pal-e-docs PR #77 — Postgres code support (already merged)
  • pal-e-docs PR #78 — k8s manifest switch (waiting on this fix + data migration)
### Plan `plan-2026-02-26-tf-modularize-postgres` -- Phase 3, Part B step 5 ("Fix SQLite-isms in migration files") ### Repo `forgejo_admin/pal-e-docs` ### User Story As a platform operator I want Alembic migrations to run cleanly against Postgres So that the SQLite-to-Postgres migration can proceed ### Context Phase 3 of the Postgres plan requires running `alembic upgrade head` against a fresh Postgres database. Two migration files use `sa.true_()` which was deprecated/removed in SQLAlchemy 2.x — the correct API is `sa.True_()` (capital T). This causes `AttributeError: module 'sqlalchemy' has no attribute 'true_'` when running migrations against Postgres. The first two migrations (initial schema, repos table) ran successfully. The users table migration fails. ### File Targets Files the agent should modify: - `alembic/versions/b2c3d4e5f6a7_add_users_table.py` line 26 — `sa.true_()` → `sa.True_()` - `alembic/versions/c3d4e5f6a7b8_add_project_is_public_and_page_note_fk.py` line 23 — `sa.true_()` → `sa.True_()` Files the agent should NOT touch: - All other migration files — only these two have the issue ### Acceptance Criteria - [ ] `sa.true_()` replaced with `sa.True_()` in both files - [ ] No other changes to migration files ### Test Expectations - [ ] `alembic upgrade head` completes without errors against Postgres - Run: port-forward to Postgres first, then `PALDOCS_DATABASE_URL=postgresql://paledocs:PfyJMdX4mPJF8eyYS38l@127.0.0.1:5432/paledocs .venv/bin/alembic upgrade head` - Note: Postgres DB may have partial schema from failed run (first 2 migrations applied). `alembic downgrade base` first if needed, or drop and recreate. ### Constraints - Two-character fix. Keep it minimal. - SQLAlchemy 2.x API: `sa.True_()` and `sa.False_()` are the correct forms ### Checklist - [ ] PR opened - [ ] Tests pass - [ ] No unrelated changes ### Related - `plan-2026-02-26-tf-modularize-postgres` Phase 3 — this blocks data migration - pal-e-docs PR #77 — Postgres code support (already merged) - pal-e-docs PR #78 — k8s manifest switch (waiting on this fix + data migration)
Commenting is not possible because the repository is archived.
No milestone
No project
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ldraney/pal-e-api#79
No description provided.