2

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)

2 Answers 2

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"
Sign up to request clarification or add additional context in comments.

Comments

2

Create another migration

change_column :users, :admin, :boolean, :default => false

Same question as Add a default value to a column through a migration

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.