Skip to content

fix: support concurrent indexes in shadow db replay#5799

Open
zacharyliu wants to merge 1 commit intoprisma:mainfrom
zacharyliu:fix/shadow-db-multiple-concurrent-indexes
Open

fix: support concurrent indexes in shadow db replay#5799
zacharyliu wants to merge 1 commit intoprisma:mainfrom
zacharyliu:fix/shadow-db-multiple-concurrent-indexes

Conversation

@zacharyliu
Copy link
Copy Markdown

@zacharyliu zacharyliu commented Mar 26, 2026

Support for multiple CREATE INDEX CONCURRENTLY statements in migrations was added in #5767. Shadow DB migration replay still used a separate raw SQL execution path, causing shadow creation to fail if a migration existed with multiple CREATE INDEX CONCURRENTLY:

Error: P3006

Migration `20260316120000_<migration_name>` failed to apply cleanly to the shadow database. 
Error:
ERROR: CREATE INDEX CONCURRENTLY cannot run inside a transaction block
   0: schema_core::state::DevDiagnostic
             at schema-engine/core/src/state.rs:314

This PR updates the shadow database migration path to use the new migration script logic.

This fixes the issue in prisma/prisma#14456 (comment).

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved PostgreSQL database migration execution with enhanced handling for concurrent index operations
    • Increased reliability in migration application

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2de92956-e78a-4870-b2d8-30a17f89c58f

📥 Commits

Reviewing files that changed from the base of the PR and between 75cbdc1 and c063b81.

📒 Files selected for processing (2)
  • schema-engine/connectors/sql-schema-connector/src/flavour/postgres.rs
  • schema-engine/sql-migration-tests/tests/migrations/postgres.rs

Walkthrough

Updates the PostgreSQL migration execution path to use apply_migration_script instead of raw_cmd, and adds a new test verifying correct handling of multiple CREATE INDEX CONCURRENTLY statements during migration generation.

Changes

Cohort / File(s) Summary
Migration Execution Path
schema-engine/connectors/sql-schema-connector/src/flavour/postgres.rs
Changed migration application to call apply_migration_script() instead of raw_cmd(), removing explicit error mapping that is now handled internally.
Postgres Migration Tests
schema-engine/sql-migration-tests/tests/migrations/postgres.rs
Added test postgres_create_migration_works_with_multiple_create_index_concurrently_statements that verifies migrations with multiple CREATE INDEX CONCURRENTLY statements are applied correctly.
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: support concurrent indexes in shadow db replay' directly matches the main change: updating shadow database migration replay to handle multiple CREATE INDEX CONCURRENTLY statements.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 26, 2026

CLA assistant check
All committers have signed the CLA.

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.

2 participants