Commit 2e564ddf authored by Stan Hu's avatar Stan Hu

Fix duplicate key errors in PostDeployMigrateUserExternalMailData migration

`email_provider` by default is NULL, and if a user had not logged the
value would remain NULL. Upgrading to GitLab 10.0 would lead to a
PG::UniqueViolation because the post-deploy migration would attempt
to reinsert the entry because the NULL comparison between
`users.email_provider` and `user_synced_attributes_metadata.email_provider`
would never match.

Closes #38246
parent 024d10b7
Pipeline #12057423 passed with stages
in 50 minutes and 52 seconds
---
title: Fix duplicate key errors in PostDeployMigrateUserExternalMailData migration
merge_request:
author:
type: fixed
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment