cartodb-4.42/db/migrate/20150915141325_change_synchronization_id_to_uuid.rb

26 lines
891 B
Ruby
Raw Normal View History

2024-04-06 13:25:13 +08:00
Sequel.migration do
up do
# INFO: Careful, order matters!
SequelRails.connection.run(%{
ALTER TABLE data_imports ALTER COLUMN synchronization_id TYPE uuid USING synchronization_id ::uuid;
})
SequelRails.connection.run(%{
ALTER TABLE external_data_imports DROP CONSTRAINT synchronization_id_fkey;
})
SequelRails.connection.run(%{
ALTER TABLE external_data_imports ALTER COLUMN synchronization_id TYPE uuid USING synchronization_id ::uuid;
})
SequelRails.connection.run(%{
ALTER TABLE synchronizations ALTER COLUMN id TYPE uuid USING id ::uuid;
})
SequelRails.connection.run(%{
ALTER TABLE external_data_imports
ADD CONSTRAINT synchronization_id_fkey FOREIGN KEY (synchronization_id)
REFERENCES synchronizations (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE CASCADE;
})
end
down do
end
end