It is a no-op inside a transaction, that's why it has to happen outside.
One solution currently is to set @disable_ddl_transaction true, running the PRAGMA, then opening a transaction by hand in the migration. However that way, the migration transaction commits inside up/0, and the schema_migrations row is only written afterwards, outside the transaction.
If something fails in between, the schema has changed but the migration isn't recorded. Running it again either fails with a confusing error ("there is already another table with this name") or applies the migration a second time.
Is there a way to run a migration inside a transaction together with the schema_migrations update, while running the required PRAGMA outside?
If there is not, the proposal would be optional before_begin/0 and after_commit/0 callbacks, run outside the transaction but on the same checked-out connection, so a PRAGMA set in before_begin applies to the transaction that follows.
What do you think?