Which schema changes in PostgreSQL block reads or writes on a live table, why each one does, and the safer sequence of statements to use in its place.
A PostgreSQL migration is risky for a live application when it requests a strong table lock and keeps it while a lengthy scan or table rebuild runs. Four everyday statements do that: adding a column with a default that changes per row, turning on NOT NULL for a column with existing rows, creating an index in the plain way, and adding a foreign key or check constraint that validates every row at once. Each has a safer form made of two or three smaller steps, and the extra steps cost little compared with a table that stops answering for the length of a scan.
Read the full report on AISkills402: https://aiskills402.com/blog/postgres-migration-locks?utm_source=devto&utm_medium=social
