Since you're going the route of adding a new enum value through SQL, I'm going to guess that you defined the column to be an enum also through SQL. So
using Postgres's Documentation:
ALTER TYPE name ADD VALUE new_enum_value [ { BEFORE | AFTER } existing_enum_value ]
Give this a shot:
def up
execute <<-SQL
ALTER TYPE blood ADD VALUE 'NA';
SQL
end
def down
execute <<-SQL
ALTER TYPE blood DROP VALUE 'NA';
SQL
end
Another way of going about enums in Rails is by having the enum defined in the model. So what you can do is have your model have an attribute (called blood) be of type integer. Then in the model you can do:
class Model < ApplicationRecord
enum blood: [
:A,
:B,
:AB,
:O,
:NA
]
end
This way when you want to modify the values of the enum, you don't have to create another migration. Another benefit to doing it this way is you get to use strings (or symbols) as the value for the enum. I.e.:
# Both work
model.update_attributes(blood: 'O')
model.update_attributes(blood: :O)
And when you access the blood attribute, you still get a string back:
puts model.blood # => "O"
blood? And how did you define it to be an enum?