Great suggestion, thank you!
Done - https://github.com/AdmTal/PostgreSQL-Query-Lock-Explainer/co...
As far as I know, truncate can be rolled back but it is also visible, even before the transaction is commited, to other transactions that started before:
Ah thank you! Quoting the link for others;
> TRUNCATE is not MVCC-safe. After truncation, the table will appear empty to concurrent transactions, if they are using a snapshot taken before the truncation occurred. See Section 13.6 for more details.
> TRUNCATE is transaction-safe with respect to the data in the tables: the truncation will be safely rolled back if the surrounding transaction does not commit.
Maybe emitting a warning would be good. I'm no DBA so remembering all operations that cannot be rolledback might be tough. (Though maybe I should know all of them if they aren't rollbackable :P )
I’m often worrying about locks in migrations that could be long running, so executing the query to figure out the locks defeats the purpose. Or at least I need to know to use a test DB.