cartodb-4.42/db/migrate/20140516125339_add_user_id_to_visualizations.rb
2024-04-06 05:25:13 +00:00

20 lines
463 B
Ruby

Sequel.migration do
up do
add_column :visualizations, :user_id, :uuid
SequelRails.connection.transaction do
SequelRails.connection.run(%Q{
UPDATE visualizations
SET user_id = maps.user_id FROM maps
WHERE maps.user_id IN (SELECT users.id FROM users)
AND visualizations.user_id IS NULL
AND visualizations.map_id = maps.id
})
end
end
down do
drop_column :visualizations, :user_id
end
end