Files
ubicloud/migrate/20250228_project_id_location_indexes_to_id.rb
Furkan Sahin 056e11e0a4 Make location references a foreign key, create indexes - Mig 1
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.
2025-03-23 15:48:19 +01:00

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