Both of these tables has parent_id column referencing themselves. They are used in forks to refer the parent PostgresResource and PostgresTimeline. Foreign key constraints prevents deletion of the parent entity while the child entity is still around, so we are removing the constraint.
26 lines
596 B
Ruby
26 lines
596 B
Ruby
# frozen_string_literal: true
|
|
|
|
Sequel.migration do
|
|
# When column names are passed in array form, Sequel only drops or creates
|
|
# the constraint, without touching to the column itself.
|
|
up do
|
|
alter_table(:postgres_resource) do
|
|
drop_foreign_key [:parent_id]
|
|
end
|
|
|
|
alter_table(:postgres_timeline) do
|
|
drop_foreign_key [:parent_id]
|
|
end
|
|
end
|
|
|
|
down do
|
|
alter_table(:postgres_resource) do
|
|
add_foreign_key([:parent_id], :postgres_resource)
|
|
end
|
|
|
|
alter_table(:postgres_timeline) do
|
|
add_foreign_key([:parent_id], :postgres_timeline)
|
|
end
|
|
end
|
|
end
|