Fix sa.true_() -> sa.True_() for SQLAlchemy 2.x compatibility #80

Merged
forgejo_admin merged 1 commit from 79-fix-alembic-sa-true into main 2026-03-06 19:18:36 +00:00
Contributor

Summary

Fixes AttributeError: module 'sqlalchemy' has no attribute 'true_' when running Alembic migrations against Postgres. Two-character fix: sa.true_() to sa.True_() in two migration files.

Changes

  • alembic/versions/b2c3d4e5f6a7_add_users_table.py: sa.true_() changed to sa.True_() on line 26
  • alembic/versions/c3d4e5f6a7b8_add_project_is_public_and_page_note_fk.py: sa.true_() changed to sa.True_() on line 23

Test Plan

  • Tests pass locally (299 passed)
  • Verified sa.True_() is valid in SQLAlchemy 2.0.46
  • Manual verification: port-forward to Postgres, run alembic upgrade head

Review Checklist

  • Passed automated review-fix loop
  • No secrets committed
  • No unnecessary file changes
  • Commit messages are descriptive
  • plan-2026-02-26-tf-modularize-postgres -- Phase 3 blocker (step 5: fix SQLite-isms)
  • Forgejo issue: #79
## Summary Fixes `AttributeError: module 'sqlalchemy' has no attribute 'true_'` when running Alembic migrations against Postgres. Two-character fix: `sa.true_()` to `sa.True_()` in two migration files. ## Changes - `alembic/versions/b2c3d4e5f6a7_add_users_table.py`: `sa.true_()` changed to `sa.True_()` on line 26 - `alembic/versions/c3d4e5f6a7b8_add_project_is_public_and_page_note_fk.py`: `sa.true_()` changed to `sa.True_()` on line 23 ## Test Plan - [x] Tests pass locally (299 passed) - [x] Verified `sa.True_()` is valid in SQLAlchemy 2.0.46 - [ ] Manual verification: port-forward to Postgres, run `alembic upgrade head` ## Review Checklist - [x] Passed automated review-fix loop - [x] No secrets committed - [x] No unnecessary file changes - [x] Commit messages are descriptive ## Related Notes - `plan-2026-02-26-tf-modularize-postgres` -- Phase 3 blocker (step 5: fix SQLite-isms) - Forgejo issue: #79
Fix sa.true_() -> sa.True_() for SQLAlchemy 2.x compatibility
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
13f5d0f0e0
Closes #79

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
Contributor

PR #80 Review

BLOCKERS

None.

NITS

  • The PR body section is titled "## Related Notes" rather than the standard "## Related". Minor template deviation, non-blocking.
  • Test Plan has an unchecked manual verification item (port-forward to Postgres, run alembic upgrade head). This is expected for a pre-migration PR and not a blocker -- the fix will be verified as part of the Phase 3 Postgres migration deployment.

SOP COMPLIANCE

  • Branch named after issue (79-fix-alembic-sa-true references issue #79)
  • PR body follows template (Summary, Changes, Test Plan, Related)
  • Related references plan slug (plan-2026-02-26-tf-modularize-postgres)
  • No secrets committed
  • No unnecessary file changes (exactly 2 files, 2 lines each, no scope creep)
  • Commit messages are descriptive

CODE REVIEW

The fix is correct. sa.true_() (lowercase) is a SQLAlchemy 1.x function-style API that was removed or relocated in SQLAlchemy 2.x. sa.True_() (capitalized) is the proper SQLAlchemy 2.x ColumnElement constant for boolean TRUE server defaults. Both changed files are Alembic migration scripts using server_default= for boolean columns, which is the exact context where this matters for Postgres compatibility.

Diff is minimal and surgical -- two identical one-character capitalization fixes across two migration files. No risk of side effects.

VERDICT: APPROVED

## PR #80 Review ### BLOCKERS None. ### NITS - The PR body section is titled "## Related Notes" rather than the standard "## Related". Minor template deviation, non-blocking. - Test Plan has an unchecked manual verification item (port-forward to Postgres, run `alembic upgrade head`). This is expected for a pre-migration PR and not a blocker -- the fix will be verified as part of the Phase 3 Postgres migration deployment. ### SOP COMPLIANCE - [x] Branch named after issue (`79-fix-alembic-sa-true` references issue #79) - [x] PR body follows template (Summary, Changes, Test Plan, Related) - [x] Related references plan slug (`plan-2026-02-26-tf-modularize-postgres`) - [x] No secrets committed - [x] No unnecessary file changes (exactly 2 files, 2 lines each, no scope creep) - [x] Commit messages are descriptive ### CODE REVIEW The fix is correct. `sa.true_()` (lowercase) is a SQLAlchemy 1.x function-style API that was removed or relocated in SQLAlchemy 2.x. `sa.True_()` (capitalized) is the proper SQLAlchemy 2.x `ColumnElement` constant for boolean TRUE server defaults. Both changed files are Alembic migration scripts using `server_default=` for boolean columns, which is the exact context where this matters for Postgres compatibility. Diff is minimal and surgical -- two identical one-character capitalization fixes across two migration files. No risk of side effects. ### VERDICT: APPROVED
forgejo_admin deleted branch 79-fix-alembic-sa-true 2026-03-06 19:18:36 +00:00
Commenting is not possible because the repository is archived.
No description provided.