Skip to content

fix: align migration 206 schema with 201-204 and harden CI#4

Open
mcp-tool-shop wants to merge 2 commits intomainfrom
fix/ci-migration-schema-conflicts
Open

fix: align migration 206 schema with 201-204 and harden CI#4
mcp-tool-shop wants to merge 2 commits intomainfrom
fix/ci-migration-schema-conflicts

Conversation

@mcp-tool-shop
Copy link
Copy Markdown
Member

Summary

  • Root cause: Migration 206 (impossible state constraints) referenced wrong table names (psp_balance_reservation instead of psp_reservation, psp_funding_request instead of funding_request), used mismatched CHECK constraint enum values vs the CREATE TABLE definitions in migrations 201-203, and the liability_event table was missing from the psp_build_pack_v2 migration path entirely.
  • Migration fixes: Added 204_liability_attribution.sql to psp_build_pack_v2/ so migrate.py creates the liability_event table before 206 runs. Fixed all CHECK constraint enums in 206 to match their source migrations (entry_type, payment status/purpose/payee_type, settlement status, reservation status, funding_request status, liability recovery_status). Fixed amount to loss_amount for liability_event. Aligned status transition trigger JSONB maps. Removed duplicate unique indexes already created in 201/202.
  • CI hardening: Added paths: filter (pyproject.toml, src/, tests/, psp_build_pack_v2/**, etc.) to prevent CI runs on doc-only changes. Added concurrency group with cancel-in-progress: true. Added workflow_dispatch: for manual trigger fallback.

Test plan

  • CI db-tests job passes: python scripts/migrate.py applies all 6 migrations (201-206) without errors
  • CI constraint-tests job passes: negative amount insertion is rejected by CHECK constraint
  • CI migration-lint job passes: migration numbering is sequential (201, 202, 203, 204, 205, 206)
  • CI demo-test job passes: example runs after migrations applied
  • Verify paths filter works: pushing a README-only change should NOT trigger CI
  • Verify concurrency: pushing twice rapidly cancels the first run

🤖 Generated with Claude Code

mcp-tool-shop and others added 2 commits February 22, 2026 09:58
Migration 206 (impossible state constraints) failed because it referenced
wrong table names (psp_balance_reservation, psp_funding_request), used
mismatched CHECK constraint enum values vs the CREATE TABLE definitions
in 201-203, and referenced liability_event.amount instead of loss_amount.

Changes:
- Add 204_liability_attribution.sql to psp_build_pack_v2 migrations so
  migrate.py can find the liability_event table before 206 runs
- Fix 206: correct table names (psp_reservation, funding_request)
- Fix 206: align all CHECK enums with 201-204 definitions (entry_type,
  payment status/purpose/payee_type, settlement status, reservation
  status, funding_request status, liability recovery_status)
- Fix 206: use loss_amount instead of amount for liability_event
- Fix 206: align status transition trigger JSONB maps with valid statuses
- Fix 206: remove duplicate unique indexes already created in 201/202
- CI: add paths filter to avoid unnecessary runs on doc-only changes
- CI: add concurrency group with cancel-in-progress
- CI: add workflow_dispatch for manual trigger

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…use raw DBAPI execution

The `timestamp` column name in psp_domain_event is a PostgreSQL reserved
keyword that causes syntax errors in RETURNS TABLE clauses. Quote it as
"timestamp" throughout migration 205.

Additionally, switch migrate.py from conn.execute(text(sql)) to raw DBAPI
cursor execution so that PL/pgSQL percent signs (%ROWTYPE, RAISE EXCEPTION
format specifiers) are passed through verbatim to PostgreSQL instead of
being interpreted as psycopg2 parameter markers. This also future-proofs
migration 206 which has RAISE EXCEPTION '%' patterns.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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