This commit adds the location foreign_keys to all of the models that uses location. This way, we will not be matching the text values but make use of the database relationship. We are refilling the location_ids based on the location column of the entities. We are also adding a new index on project_id, location_id, name because we already had an index on project_id, location, name and it will be dropped once the location column is dropped.
18 lines
606 B
Ruby
18 lines
606 B
Ruby
# frozen_string_literal: true
|
|
|
|
Sequel.migration do
|
|
no_transaction
|
|
|
|
up do
|
|
%i[postgres_resource firewall private_subnet vm minio_cluster kubernetes_cluster].each do |table|
|
|
add_index table, [:project_id, :location_id, :name], name: :"#{table}_project_id_location_id_name_uidx", unique: true, concurrently: true
|
|
end
|
|
end
|
|
|
|
down do
|
|
%i[postgres_resource firewall private_subnet vm minio_cluster kubernetes_cluster].each do |table|
|
|
add_index table, [:project_id, :location, :name], name: :"#{table}_project_id_location_name_uidx", unique: true, concurrently: true
|
|
end
|
|
end
|
|
end
|