# MP025: ban-concurrent-in-transaction **Severity**: Critical | **Auto-fixable**: No | **Tier**: Free ## What It Detects CONCURRENTLY operations (CREATE INDEX, DROP INDEX, REINDEX) cannot run inside a transaction block. PostgreSQL will raise an ERROR at runtime. ## Why It's Dangerous CONCURRENTLY operations cannot run inside a transaction block -- PostgreSQL will raise a runtime ERROR, causing the entire migration to fail. Many migration frameworks wrap operations in transactions by default, making this a common trap. ## Bad Example ```sql BEGIN; CREATE INDEX CONCURRENTLY idx_users_email ON users (email); COMMIT; ``` ## Good Example ```sql -- Run outside a transaction block: -- CONCURRENTLY operations manage their own locking. CREATE INDEX CONCURRENTLY idx_users_email ON users (email); ``` ## Auto-fix `migrationpilot analyze --fix` fixes this. Lift the CONCURRENTLY statement out of its BEGIN/COMMIT block when it is the first, last, or only statement in it. See [auto-fix](../auto-fix.md). ## Configuration ```yaml rules: MP025: false # disable MP025: severity: warning # change severity ``` ## Related Rules - [MP001](./MP001.md) require-concurrent-index-creation -- CREATE INDEX should use CONCURRENTLY - [MP009](./MP009.md) require-drop-index-concurrently -- DROP INDEX should use CONCURRENTLY - [MP008](./MP008.md) no-multi-ddl-transaction -- avoid wrapping DDL in transactions