I have a Sequel migration in PostgreSQL, which works up, but not down:
Sequel.migration do
change do
alter_table(:files) do
add_unique_constraint [:name, :folder]
end
end
end
When trying to migrate down from this block, Sequel's error message says this is an "irreversible migration" and suggests writing my "own down method".
How do I write the down method for this particular migration?
Per the docs:
Sequel.migration do
up do
alter_table(:files) do
add_unique_constraint [:name, :folder]
end
end
down do
alter_table(:files) do
drop_constraint(:your_constraint_name, :type=>:unique)
end
end
end
You will have to figure out the name of your uniqueness constraint. It should appear in your schema, and it should be something like index_files_on_name_and_folder
.