summaryrefslogtreecommitdiff
path: root/app/models/user.rb
diff options
context:
space:
mode:
authorAdam Hegyi <ahegyi@gitlab.com>2019-07-15 21:07:54 +0000
committerMayra Cabrera <mcabrera@gitlab.com>2019-07-15 21:07:54 +0000
commit4959d8fd4967e5769c8c81bf37e18ea13f607e2b (patch)
treec8983a05de4aca907d104106206e6987d3f61706 /app/models/user.rb
parentd8f7017ab01333b51b823035b177446ec36259d8 (diff)
downloadgitlab-ce-4959d8fd4967e5769c8c81bf37e18ea13f607e2b.tar.gz
Migrate null values for users.private_profile
- Background migration for changing null values to false - Set false as default value for private_profile DB column
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 02637b70f03..0fd3daa3383 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -185,6 +185,7 @@ class User < ApplicationRecord
before_validation :set_notification_email, if: :new_record?
before_validation :set_public_email, if: :public_email_changed?
before_validation :set_commit_email, if: :commit_email_changed?
+ before_save :default_private_profile_to_false
before_save :set_public_email, if: :public_email_changed? # in case validation is skipped
before_save :set_commit_email, if: :commit_email_changed? # in case validation is skipped
before_save :ensure_incoming_email_token
@@ -1491,6 +1492,12 @@ class User < ApplicationRecord
private
+ def default_private_profile_to_false
+ return unless private_profile_changed? && private_profile.nil?
+
+ self.private_profile = false
+ end
+
def has_current_license?
false
end