Jonathan Clark
Jonathan Clark

Reputation: 20538

Add default value to an already created column

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!

Upvotes: 1

Views: 83

Answers (1)

user229044
user229044

Reputation: 239240

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

def up
  change_column :tasks, :my_column, :integer, :default => 1
end

Upvotes: 4

Related Questions