Skip to content

fix(prisma): reorder webhook query indexes migration after table creation - #629

Open
OAKVISUALZ wants to merge 1 commit into
Neurowealth:mainfrom
OAKVISUALZ:fix/webhook-query-indexes-migration-order
Open

OAKVISUALZ wants to merge 1 commit into
Neurowealth:mainfrom
OAKVISUALZ:fix/webhook-query-indexes-migration-order

Conversation

@OAKVISUALZ

Copy link
Copy Markdown
Contributor

Description

Fixes the CI failure in Node CI where npx prisma migrate deploy crashed with:

ERROR: relation "user_webhook_deliveries" does not exist
Migration name: 20261003_001_add_webhook_query_indexes

Root Cause

Prisma discovers and runs migrations in lexicographical (alphabetical) order by directory name. Because ASCII '0' (48) precedes ASCII 'a' (97), 20261003_001_add_webhook_query_indexes sorted and executed before 20261003_add_missing_models.

Since user_webhook_deliveries is defined and created inside 20261003_add_missing_models, any fresh database deployment failed when 20261003_001_add_webhook_query_indexes attempted to create an index on the nonexistent table.

Solution

  1. Renamed migration directory:
    prisma/migrations/20261003_001_add_webhook_query_indexes -> prisma/migrations/20261004000000_add_webhook_query_indexes
    Using the standard 14-digit timestamp ensures it reliably executes after 20261003_add_missing_models.
  2. Added 20261003_001_add_webhook_query_indexes to FIXED_MIGRATIONS in fix-and-deploy-migrations.sh to allow automatic recovery on environments where the failed migration was recorded in _prisma_migrations.
  3. Documented the incident and recipe in docs/MIGRATIONS.md (§A.4).

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • Documentation update

Checklist

  • My code follows the existing code style of this project
  • rollback.sql ships with the migration and is idempotent
  • Documentation updated in docs/MIGRATIONS.md

…le creation

Prisma deploys migrations in lexicographical order by directory name. Because ASCII '0' precedes 'a', 20261003_001_add_webhook_query_indexes sorted before 20261003_add_missing_models, causing 'CREATE INDEX ON user_webhook_deliveries' to fail with relation does not exist.

Renamed migration to 20261004000000_add_webhook_query_indexes so it runs after table creation, added recovery handling to fix-and-deploy-migrations.sh, and documented the incident in docs/MIGRATIONS.md.
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