Reputation: 1253
I need a migration to add column of type enum in rails 3. I will be using enumerated_attribute gem.
I generated a migration to add the column:
rails generate migration addUsage_reports_accessToClientParam usage_reports_access:enum
Now I need to set up the values for the enum and set the default value. Here is the generated migration:
class AddUsageReportsAccessToClientParam < ActiveRecord::Migration
def self.up
add_column :client_params, :usage_reports_access, :enum
end
def self.down
remove_column :client_params, :usage_reports_access
end
end
Thanks
Upvotes: 2
Views: 2084
Reputation: 1253
I found a solution. This works:
add_column :client_params, :usage_reports_access, "ENUM('value1','value2', 'value3') DEFAULT 'value1'"
Upvotes: 3