How to change a nullable column to not nullable in a Rails migration? -
i created date column in previous migration , set nullable. want change not nullable. how go doing assuming there null rows in database? i'm ok setting columns time.now if they're null.
if in migration this:
# make sure no null value exist mymodel.update_all({ date_column: time.now }, { date_column: nil }) # change column not allow null change_column :my_models, :date_column, :datetime, null: false
Comments
Post a Comment