


PostgreSQL rubyonrails ActiveRecord

Avoiding PG::NotNullViolation errors when adding new columns in Rails migrations

Posted on .

I have seen this being a common question across newcomers to Rails. When you are adding a new column to an existing table with a non-null constraint, you start writing a migration as follows: This will raise a PG::NotNullViolation error as postgres is smart e…