Adding a NOT NULL Column to a Populated Table — the Expand/Contract Pattern

The ALTER TABLE ran through cleanly on your machine — on staging, the same deploy fails with column “country_code” of relation “customer” contains null values. The difference is not the SQL, it is the data: the local table was empty, the one on staging was not. If you want to add a NOT NULL column to an existing table that … Read more