I have a table in a Rails application which (in schema.rb) looks like:
create_table "users", :force => true do |t|
t.string "name", :null=>false
t.string "address", :null=>false
end
I would like to write a rails migration to allow nulls for the address field. i.e. after the migration the table looks like this:
create_table "users", :force => true do |t|
t.string "name", :null=>false
t.string "address"
end
What do I need to do to remove the constraint?
In Rails 4+ in order to remove not-null constraint, you can use change_column_null
:
change_column_null :users, :address, true