diff options
author | Robert Speicher <rspeicher@gmail.com> | 2017-09-12 18:19:39 -0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2017-09-12 18:23:07 -0400 |
commit | faefeac880a634679db0dc2a74cc9ff938cf9713 (patch) | |
tree | bcdc0e7389e8755c42ef9a58283492e9672d00fe /db | |
parent | f92e8d224c195b6b296252dd30235bb3e7c18beb (diff) | |
download | gitlab-ce-faefeac880a634679db0dc2a74cc9ff938cf9713.tar.gz |
Remove db/migrate/20170828135939_migrate_user_external_mail_data.rb
This file is a duplicate of a post-deploy migration and appears to have
been left in by mistake.
Looping through the Users table in a foreground migration would've been
a bad idea.
[ci skip]
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20170828135939_migrate_user_external_mail_data.rb | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/db/migrate/20170828135939_migrate_user_external_mail_data.rb b/db/migrate/20170828135939_migrate_user_external_mail_data.rb deleted file mode 100644 index 592e141b7e6..00000000000 --- a/db/migrate/20170828135939_migrate_user_external_mail_data.rb +++ /dev/null @@ -1,57 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class MigrateUserExternalMailData < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - class User < ActiveRecord::Base - self.table_name = 'users' - - include EachBatch - end - - class UserSyncedAttributesMetadata < ActiveRecord::Base - self.table_name = 'user_synced_attributes_metadata' - - include EachBatch - end - - def up - User.each_batch do |batch| - start_id, end_id = batch.pluck('MIN(id), MAX(id)').first - - execute <<-EOF - INSERT INTO user_synced_attributes_metadata (user_id, provider, email_synced) - SELECT id, email_provider, external_email - FROM users - WHERE external_email = TRUE - AND NOT EXISTS ( - SELECT true - FROM user_synced_attributes_metadata - WHERE user_id = users.id - AND provider = users.email_provider - ) - AND id BETWEEN #{start_id} AND #{end_id} - EOF - end - end - - def down - UserSyncedAttributesMetadata.each_batch do |batch| - start_id, end_id = batch.pluck('MIN(id), MAX(id)').first - - execute <<-EOF - UPDATE users - SET users.email_provider = metadata.provider, users.external_email = metadata.email_synced - FROM user_synced_attributes_metadata as metadata, users - WHERE metadata.email_synced = TRUE - AND metadata.user_id = users.id - AND id BETWEEN #{start_id} AND #{end_id} - EOF - end - end -end |