Postgres locks and further reading
The Postgres docs on "Explicit Locking" provide excellent information on Postgres lock levels in and their interactions.
Braintree's "PostgreSQL at Scale: Database Schema Changes Without Downtime" has practical examples of different schema changes, the locks required for them and how to safely make those changes. Their earlier "Safe Operations For High Volume PostgreSQL" provides more concise examples of schema changes and their workarounds to make them safe.
Citus's "When Postgres blocks: 7 tips for dealing with locks" has some examples of schema changes and how to make them safely.
GoCardless's "Zero-downtime Postgres migrations - the hard parts" and Benchling's "Move fast and migrate things: how we automated migrations in Postgres" documents how to set lock timeouts to safely apply migrations.
The Postgres docs on "Alter Table" have notes on the database behavior of table modifications. This is an excellent resource for understanding how certain schema changes will be applied at the database.
Please see "Applying migrations safely" for information about setting the necessary lock timeouts to safely apply migrations in a production environment.