# AZ615: A migration run outside a transaction

A policy migration is one transaction: it uses temporary tables and settings that end with it, and its statements only make sense together. This one was run a statement at a time, each committed on its own (`psql -f` does that), where a change to inheritance would stop half way with the old trees dropped. So it refused before changing anything, and made the session read-only, since psql goes on after an error unless told to stop. The migration's last statement puts the setting back, so a connection a pooler hands to another client next isn't left read-only. Run it with your migration tool, which wraps each migration in a transaction, or `psql -1 -v ON_ERROR_STOP=1 -f <file>`, on a direct connection to Postgres: through a pooler in transaction mode, the last statement may run on another server connection, and the first one stays read-only.

Reported when a policy migration runs.
