I added new migration that add a new column to a table. I ran the command 'rake db:migrate' Then I realize that I forgot to add a default value. How can I add default value after the rake db:migrate? (I'm storing the server on heroku service)
Asked
Active
Viewed 127 times
2 Answers
2
Create another migration
change_column :users, :admin, :boolean, :default => false
Same question as Add a default value to a column through a migration

Community
- 1
- 1

Steve Wilhelm
- 6,200
- 2
- 32
- 36
2
You can run rake db:rollback
, then adjust your migration with default value, commit and push to heroku, and then run db:migrate again.
Another option is to create a new migration and use change_column_default:
change_column_default :table_name, :column_name, "Default value"