If you’re adding or modifying a column in Postgres and you get this error, maybe it’s because you are changing a type to NOT NULL but the column already exists, with null values, or you’re adding one and the default is in fact NULL. That means you have to specify a default value for the field.
For example, I just added an integer field to a table called newsletter_newsletter:
ALTER TABLE newsletter_newsletter ADD COLUMN opened integer NOT NULL default 0;
Sometimes, I forget.
PostgreSQL is a sleeping giant that will one day break and destroy me. I just sit here hoping it runs smoothly, forever.
Google led me here when searching for ‘column contains null values’. Adding ‘default 0’ cleared that up for me. Thanks!!