concurrently-in-transaction
errorCONCURRENTLY inside a transaction
Why it's unsafe
CREATE/DROP INDEX CONCURRENTLY, REINDEX CONCURRENTLY, and ALTER TABLE … DETACH PARTITION … CONCURRENTLY cannot run inside a transaction block; this statement runs inside a transaction and will fail at runtime. Because of this, --fix/--diff will not add CONCURRENTLY to a statement inside a transaction — the finding is reported without an automatic fix.
Safe rewrite
Run the CONCURRENTLY statement outside the transaction — put it in its own migration, or move it before BEGIN / after COMMIT. (Note: many migration tools also wrap each migration in an implicit transaction; disable that for this migration.)
Example
Try it in the playground →Unsafe
BEGIN;
CREATE INDEX CONCURRENTLY idx_users_email ON users (email);
COMMIT;Safe
CREATE INDEX CONCURRENTLY idx_users_email ON users (email);