Set lock_timeout before any ALTER TABLE
ALTER TABLE waits for a lock, and while it waits every query behind it queues too. One long-running report can turn a one millisecond migration into a full outage.
SET lock_timeout = '3s';
ALTER TABLE orders ADD COLUMN note text;If the lock does not come in three seconds the migration fails and you retry when the report is done. Failing fast is the feature.
postgresqlmigrations