Q043warning

Migration is not atomic

A migration mixes a statement that cannot run in a transaction with other statements.

db/migrations/0003_index.up.sql:1:1: warning[Q043]: migration mixes a non-transactional statement (sgl.migration(no_transaction: true) or an auto-detected statement such as CREATE INDEX CONCURRENTLY) with other statements; the whole migration runs without a transaction and is not atomic, so move the non-transactional statement into its own migration file
Printed by sgl from a small PostgreSQL reproduction project.

When it is reported

sgl.migration(no_transaction: true), or a statement such as CREATE INDEX CONCURRENTLY, makes the whole file run outside a transaction, so a failure part way leaves it half applied.

How to fix it

Move the non-transactional statement into its own migration.

See it in an example

In your terminal

$ sgl explain Q043

Look for MigrationMixedTransaction in Seagull's source to see where it is reported.