I created a date column in a previous migration and set it to be nullable. Now I want to change it to be not nullable. How do I go about doing this assuming there are null rows in that database? I'm ok with setting those columns to Time.now if they're currently null.
Ruby-on-rails – How to change a nullable column to not nullable in a Rails migration
migrationruby-on-rails
Related Topic
- Ruby-on-rails – Rails: How to rename a database column in a Ruby on Rails migration
- Ruby-on-rails – How to get the current absolute URL in Ruby on Rails
- Ruby-on-rails – Rails migration for change column
- Ruby-on-rails – How to drop columns using Rails migration
- Ruby-on-rails – How to rollback a specific migration
- Ruby-on-rails – Rails DB Migration – How To Drop a Table
- Ruby-on-rails – Update one column to value of another in Rails migration
- Ruby-on-rails – How to handle too long index names in a Ruby on Rails ActiveRecord migration
Best Answer
If you do it in a migration then you could probably do it like this: