summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-09 12:09:24 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-09 12:09:24 +0000
commita9ced7da447785c57477b3d8dbccc73a78cface1 (patch)
tree5179d27ab9d801748ee4ed1c64c985974e799812 /db
parentad0265eead72a624ce7a020847db4f0f0c877e57 (diff)
downloadgitlab-ce-a9ced7da447785c57477b3d8dbccc73a78cface1.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20200312053852_populate_canonical_emails.rb35
-rw-r--r--db/structure.sql1
2 files changed, 36 insertions, 0 deletions
diff --git a/db/migrate/20200312053852_populate_canonical_emails.rb b/db/migrate/20200312053852_populate_canonical_emails.rb
new file mode 100644
index 00000000000..10efffab59c
--- /dev/null
+++ b/db/migrate/20200312053852_populate_canonical_emails.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+class PopulateCanonicalEmails < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ class User < ActiveRecord::Base
+ include EachBatch
+
+ self.table_name = 'users'
+
+ scope :with_gmail, -> { select(:id, :email).where("email ILIKE '%gmail.com'") }
+ end
+
+ # Limited to *@gmail.com addresses only as a first iteration, because we know
+ # Gmail ignores `.` appearing in the Agent name, as well as anything after `+`
+
+ def up
+ # batch size is the default, 1000
+ migration = Gitlab::BackgroundMigration::PopulateCanonicalEmails
+ migration_name = migration.to_s.demodulize
+
+ queue_background_migration_jobs_by_range_at_intervals(
+ User.with_gmail,
+ migration_name,
+ 1.minute)
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/structure.sql b/db/structure.sql
index 459d04570cc..d179c52ee6b 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -13007,6 +13007,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200311165635
20200311192351
20200311214912
+20200312053852
20200312125121
20200312160532
20200312163407