diff options
author | Adam Hegyi <ahegyi@gitlab.com> | 2019-07-15 21:07:54 +0000 |
---|---|---|
committer | Mayra Cabrera <mcabrera@gitlab.com> | 2019-07-15 21:07:54 +0000 |
commit | 4959d8fd4967e5769c8c81bf37e18ea13f607e2b (patch) | |
tree | c8983a05de4aca907d104106206e6987d3f61706 /lib | |
parent | d8f7017ab01333b51b823035b177446ec36259d8 (diff) | |
download | gitlab-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 'lib')
-rw-r--r-- | lib/api/users.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/background_migration/migrate_null_private_profile_to_false.rb | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/api/users.rb b/lib/api/users.rb index 41418aa216c..30a278fdff1 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -51,7 +51,7 @@ module API optional :can_create_group, type: Boolean, desc: 'Flag indicating the user can create groups' optional :external, type: Boolean, desc: 'Flag indicating the user is an external user' optional :avatar, type: File, desc: 'Avatar image for user' - optional :private_profile, type: Boolean, desc: 'Flag indicating the user has a private profile' + optional :private_profile, type: Boolean, default: false, desc: 'Flag indicating the user has a private profile' all_or_none_of :extern_uid, :provider use :optional_params_ee diff --git a/lib/gitlab/background_migration/migrate_null_private_profile_to_false.rb b/lib/gitlab/background_migration/migrate_null_private_profile_to_false.rb new file mode 100644 index 00000000000..32ed6a2756d --- /dev/null +++ b/lib/gitlab/background_migration/migrate_null_private_profile_to_false.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Gitlab + module BackgroundMigration + # This class is responsible for migrating a range of users with private_profile == NULL to false + class MigrateNullPrivateProfileToFalse + # Temporary AR class for users + class User < ActiveRecord::Base + self.table_name = 'users' + end + + def perform(start_id, stop_id) + User.where(private_profile: nil, id: start_id..stop_id).update_all(private_profile: false) + end + end + end +end |