Toggle NOT NULL constraints with Rails migrations
You can quickly toggle a "NOT NULL" constraint in a Rails migration with the change_column_null
method.
To add the constraint:
change_column_null :users, :email, false
To remove the constraint:
change_column_null :users, :email, true
Tweet