I have a problem when I have to add a new type of notification to a group already added by migration, the code is the following:
class CreateNotifications < ActiveRecord::Migration[5.1]
def up
execute <<-DDL
CREATE TYPE notifications_types AS ENUM (
'pending_subscription', 'approved_subscription', 'rejected_subscription', 'pending_evaluation', 'feedback_ready', 'course_capacity', 'student_feedback_ready'
);
DDL
create_table :notifications do |t|
t.column :notification_type, :notifications_types
t.integer :user_id
t.boolean :read
t.integer :course_id
t.integer :stage_id
t.integer :exercise_id
t.integer :answer_id
t.integer :feedback_id
t.json :data
t.timestamps
end
end
def down
drop_table :notifications
execute "DROP type notifications_types;"
end
end
and what I need is to add a new type of notification to the set that is above in enum but when adding and creating the migration this does not happen.
I don't see that you show how you are adding the new type, nor which DB Engine you are using, but the way to do it according to the PostgreSQL documentation is with: