fix: add partial index declarations to models for alembic check #266
No reviewers
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ldraney/pal-e-api!266
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "265-fix-add-partial-index-declarations-to-mo"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Add missing partial index declarations to SQLAlchemy models so
alembic checkstops flagging them as needing removal. Model-only change — no new migration.Changes
src/pal_e_docs/models.py— addedtextto sqlalchemy imports, addedix_blocks_block_type_mermaidpartial index to Block__table_args__, added__table_args__withix_notes_note_type_architecturepartial index to Note modelTest Plan
python -c "from pal_e_docs.models import Block, Note; print('OK')"imports cleanlyruff checkandruff formatpassalembic check) should passReview Checklist
textimported from sqlalchemyRelated Notes
None — standalone CI fix.
Related
Closes #265
QA Review
Diff Analysis
textcorrectly added to sqlalchemy imports (already hadIndex)ix_notes_note_type_architecturepartial index added to Note via new__table_args__tuple — trailing comma present, correct formix_blocks_block_type_mermaidpartial index added to Block__table_args__— inserted before the UniqueConstraint, clean placementpostgresql_where=text(...)usage is correct for declaring partial indexes in SQLAlchemyChecks
textimport present265-fix-add-partial-index-declarations-to-momatches issue #265Concerns
None.
VERDICT: APPROVED
PR #266 Review
DOMAIN REVIEW
Stack: Python / SQLAlchemy / Alembic (pal-e-docs models)
Correctness of partial index declarations:
sqlalchemy.text(lowercase) is the correct import for SQL text clauses inpostgresql_where. Verified it is added to the existing import block alphabetically betweenTextandUniqueConstraint.Index("ix_notes_note_type_architecture", "note_type", postgresql_where=text("note_type = 'architecture'"))-- correct partial index syntax. Single-column index onnote_typefiltered to architecture rows.Index("ix_blocks_block_type_mermaid", "block_type", postgresql_where=text("block_type = 'mermaid'"))-- same pattern, correct.postgresql_whereclauses usetext()wrappers, which is required for Alembic's autogenerate comparison to recognize them as matching the DB state.Model integrity:
__table_args__. The new tuple is well-formed (trailing comma present in the tuple via the closing paren placement).__table_args__preserved:ix_blocks_note_id_position,ix_blocks_anchor_id, anduq_blocks_note_id_anchor_idall untouched. New index inserted before the UniqueConstraint, which is fine -- ordering in the tuple is cosmetic.No migration created: Only
models.pymodified (1 file, +13 lines, -0 lines). No new file inalembic/versions/. This is the correct approach -- these indexes already exist in the DB; the models just need to declare them soalembic checksees parity.Alembic check compatibility: With these declarations in place,
alembic checkwill see the partial indexes in both the model metadata and the DB, eliminating the false-positive drift detection that caused CI pipeline #93 to fail.BLOCKERS
None.
NITS
u1p2q3r4s5t6as the source of these indexes, but that migration revision ID does not appear in the localalembic/versions/directory (local checkout may be behind remote main). Not blocking, but worth confirming the migration exists on the remote main branch for traceability.SOP COMPLIANCE
265-fix-add-partial-index-declarations-to-mo(follows{issue-number}-{kebab-case-purpose})PROCESS OBSERVATIONS
Minimal-risk CI fix. Change failure risk is near zero -- this is a model metadata declaration only (no DDL, no data migration, no runtime behavior change). The fix unblocks CI for all subsequent PRs, so deployment frequency impact is positive.
VERDICT: APPROVED