Closed DavidBuyCo closed 3 years ago
Hi! The error message is telling you whats wrong. Here's the important bit: cannot run inside a transaction block
It may not be obvious if you're not familiar with Rails migrations. Every migration runs inside a DB transaction by default. Sometimes that's invalid, like when you're building a concurrent index or in this case altering an enum.
Here's the relevant documentation from PostgreSQL:
ALTER TYPE ... ADD VALUE (the form that adds a new value to an enum type) cannot be executed inside a transaction block.
Here's what you should do:
class AddNewValue < ActiveRecord::Migration[5.1]
disable_ddl_transaction!
def change
add_enum_value :my_test_enum, 'FOO', before: 'BAR'
end
end
I'll update the documentation to make this more clear.
Nice, it work! thank for your answer!
Hi, thanks for your work!
I try to add a new enum value on an existing enum like the documentation
But when i run migrations, i got this error
I use this gem on a rails 5.1 application