gitlab-org--gitlab-foss/db/migrate/20150817163600_deduplicate_user_identities.rb
Hannes Rosenögger a22b6c591f fix failing migration on mysql
We didn't specify that the db user needs the right to create
temporary tables before.
That's why the migration will fail on most installations.
This commits removes the "TEMPORARY" from the migration
and changes the documentation to include the necessary rights for the future.
2015-09-18 19:49:04 +02:00

14 lines
686 B
Ruby

class DeduplicateUserIdentities < ActiveRecord::Migration
def change
execute 'DROP TABLE IF EXISTS tt_migration_DeduplicateUserIdentities;'
execute 'CREATE TABLE tt_migration_DeduplicateUserIdentities AS SELECT id,provider,user_id FROM identities;'
execute 'DELETE FROM identities WHERE id NOT IN ( SELECT MIN(id) FROM tt_migration_DeduplicateUserIdentities GROUP BY user_id, provider);'
execute 'DROP TABLE IF EXISTS tt_migration_DeduplicateUserIdentities;'
end
def down
# This is an irreversible migration;
# If someone is trying to rollback for other reasons, we should not throw an Exception.
# raise ActiveRecord::IrreversibleMigration
end
end