fix: add partial index declarations to models for alembic check #265

Open
opened 2026-04-12 17:15:59 +00:00 by forgejo_admin · 0 comments
Contributor

Type

bug

Lineage

Standalone fix — CI pipeline #93 failure

Repo

forgejo_admin/pal-e-api

User Story

As a developer, I need alembic check to pass in CI so that the migration-test pipeline step does not block merges.

What Broke

Pipeline #93 fails at migration-test because alembic check detects two partial indexes in the DB (created by migration u1p2q3r4s5t6) that are NOT declared in the SQLAlchemy models. The autogenerate comparison flags them as "should be removed."

Repro Steps

  1. Run alembic check against the current models
  2. Observe it flags ix_blocks_block_type_mermaid and ix_notes_note_type_architecture as needing removal

Expected Behavior

alembic check should pass cleanly — no detected differences between models and DB.

Environment

CI pipeline (Woodpecker), pal-e-api main branch

Context

The fix is model-only — no new migration needed since indexes already exist in DB.

File Targets

  • src/pal_e_docs/models.py — add Index declarations to Block and Note models

Acceptance Criteria

  • alembic check passes without detecting phantom index removals
  • Block model __table_args__ includes ix_blocks_block_type_mermaid partial index
  • Note model has __table_args__ with ix_notes_note_type_architecture partial index
  • text imported from sqlalchemy
  • No new migration file created

Test Expectations

  • python -c "from pal_e_docs.models import Block, Note; print('OK')" imports cleanly
  • ruff check and ruff format pass
  • alembic check no longer flags missing indexes

Constraints

  • Model-only change — do NOT create a new alembic migration
  • Indexes already exist in DB via migration u1p2q3r4s5t6

Checklist

  • Add text to sqlalchemy imports
  • Add mermaid partial index to Block __table_args__
  • Add __table_args__ with architecture partial index to Note model
  • Verify clean import
  • Run ruff
  • CI Pipeline #93 failure
### Type bug ### Lineage Standalone fix — CI pipeline #93 failure ### Repo forgejo_admin/pal-e-api ### User Story As a developer, I need alembic check to pass in CI so that the migration-test pipeline step does not block merges. ### What Broke Pipeline #93 fails at migration-test because `alembic check` detects two partial indexes in the DB (created by migration u1p2q3r4s5t6) that are NOT declared in the SQLAlchemy models. The autogenerate comparison flags them as "should be removed." ### Repro Steps 1. Run `alembic check` against the current models 2. Observe it flags `ix_blocks_block_type_mermaid` and `ix_notes_note_type_architecture` as needing removal ### Expected Behavior `alembic check` should pass cleanly — no detected differences between models and DB. ### Environment CI pipeline (Woodpecker), pal-e-api main branch ### Context The fix is model-only — no new migration needed since indexes already exist in DB. ### File Targets - `src/pal_e_docs/models.py` — add Index declarations to Block and Note models ### Acceptance Criteria - `alembic check` passes without detecting phantom index removals - Block model `__table_args__` includes `ix_blocks_block_type_mermaid` partial index - Note model has `__table_args__` with `ix_notes_note_type_architecture` partial index - `text` imported from sqlalchemy - No new migration file created ### Test Expectations - `python -c "from pal_e_docs.models import Block, Note; print('OK')"` imports cleanly - `ruff check` and `ruff format` pass - `alembic check` no longer flags missing indexes ### Constraints - Model-only change — do NOT create a new alembic migration - Indexes already exist in DB via migration u1p2q3r4s5t6 ### Checklist - [ ] Add `text` to sqlalchemy imports - [ ] Add mermaid partial index to Block `__table_args__` - [ ] Add `__table_args__` with architecture partial index to Note model - [ ] Verify clean import - [ ] Run ruff ### Related - CI Pipeline #93 failure
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#265
No description provided.