1

I am building an Rails 3.2.6 app and I need to add a default value to a column on an already created table called tasks. How can I do this with a migration?

Thanks!

1
  • Write a alter migration with default value Commented Oct 30, 2012 at 14:30

1 Answer 1

4

Use change_column(table_name, column_name, type, options = {}):

def up
  change_column :tasks, :my_column, :integer, :default => 1
end
Sign up to request clarification or add additional context in comments.

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.