How to change a nullable column to not nullable in a Rails migration?

If you do it in a migration then you could probably do it like this.

If you do it in a migration then you could probably do it like this: # Make sure no null value exist MyModel. Update_all(:date_column => Time. Now, :date_column => nil) # Change the column to not allow null change_column :my_models, :date_column, :datetime, :null => false.

Create a migration that has an change_column statement with a :default => value. Change_column :my_table, :my_column, :integer, :default => 0, :null => false See: change_column Depending on the database engine you may need to use change_column_null.

1 This worked for me. Using MySql locally. When pushed and ran app in Heroku (Postgres) it crapped on column that was not null when I was writing it a null - rightfully so.

Only "change_column_null" would work could not use "change_column ... :null => false" on MySql. Thanks. – rtfminc Jul 3 at 19:27.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions