Take advantage of change_column_null to add or remove NOT NULL constraint on a column. The null flag indicates whether the value can be NULL.
To add the constraint (says column cannot be NULL):
change_column_null :users, :name, falseTo remvoe the constraint (allows column to be NULL):
change_column_null :users, :name, trueThe method accepts an optional fourth argument to replace existing +NULL+s with some other value. Use that one when enabling the constraint if needed, since otherwise those rows would not be valid.
Note: Please note the fourth argument does not set a column’s default.