summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2017-09-23 12:30:59 +0000
committerYorick Peterse <yorickpeterse@gmail.com>2017-09-23 12:30:59 +0000
commitb14641579855a14398db260ab909ae77c164c883 (patch)
tree9e3bccd0b895032e2081ec917d993e96e350efdc
parent024d10b7adabe4ca2fc42107837367cb086fe75c (diff)
parent2e564ddfc7ac500b72051d56b9a6b37979296c0e (diff)
downloadgitlab-ce-b14641579855a14398db260ab909ae77c164c883.tar.gz
Merge branch 'sh-fix-issue-38246' into 'master'
Fix duplicate key errors in PostDeployMigrateUserExternalMailData migration Closes #38246 See merge request gitlab-org/gitlab-ce!14460
-rw-r--r--changelogs/unreleased/sh-fix-issue-38246.yml5
-rw-r--r--db/migrate/20170828135939_migrate_user_external_mail_data.rb2
-rw-r--r--db/post_migrate/20170828170502_post_deploy_migrate_user_external_mail_data.rb2
3 files changed, 7 insertions, 2 deletions
diff --git a/changelogs/unreleased/sh-fix-issue-38246.yml b/changelogs/unreleased/sh-fix-issue-38246.yml
new file mode 100644
index 00000000000..8a127559fbb
--- /dev/null
+++ b/changelogs/unreleased/sh-fix-issue-38246.yml
@@ -0,0 +1,5 @@
+---
+title: Fix duplicate key errors in PostDeployMigrateUserExternalMailData migration
+merge_request:
+author:
+type: fixed
diff --git a/db/migrate/20170828135939_migrate_user_external_mail_data.rb b/db/migrate/20170828135939_migrate_user_external_mail_data.rb
index 592e141b7e6..395181a3b22 100644
--- a/db/migrate/20170828135939_migrate_user_external_mail_data.rb
+++ b/db/migrate/20170828135939_migrate_user_external_mail_data.rb
@@ -33,7 +33,7 @@ class MigrateUserExternalMailData < ActiveRecord::Migration
SELECT true
FROM user_synced_attributes_metadata
WHERE user_id = users.id
- AND provider = users.email_provider
+ AND provider = users.email_provider OR (provider IS NULL AND users.email_provider IS NULL)
)
AND id BETWEEN #{start_id} AND #{end_id}
EOF
diff --git a/db/post_migrate/20170828170502_post_deploy_migrate_user_external_mail_data.rb b/db/post_migrate/20170828170502_post_deploy_migrate_user_external_mail_data.rb
index fefd931e5d2..a475b242921 100644
--- a/db/post_migrate/20170828170502_post_deploy_migrate_user_external_mail_data.rb
+++ b/db/post_migrate/20170828170502_post_deploy_migrate_user_external_mail_data.rb
@@ -33,7 +33,7 @@ class PostDeployMigrateUserExternalMailData < ActiveRecord::Migration
SELECT true
FROM user_synced_attributes_metadata
WHERE user_id = users.id
- AND provider = users.email_provider
+ AND provider = users.email_provider OR (provider IS NULL AND users.email_provider IS NULL)
)
AND id BETWEEN #{start_id} AND #{end_id}
EOF