Rails Migration to create a column null => true
I originally created a table with a column
t.string "email", :default => "", :null => false The requirement has changed, and now I need the email to be empty. How to write a migration to do: null => true
Try:
change_column :table_name, :email, :string, :null => true I could not get the above solution to work with Active Record 4.0.8 and Postgresql 9.3
However, change_column_null worked fine.
change_column_null :users, :email, true Reverse has the good ability to update existing records (but not set by default) when null is not allowed.