Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Hegyi <ahegyi@gitlab.com>2019-07-16 00:07:54 +0300
committerMayra Cabrera <mcabrera@gitlab.com>2019-07-16 00:07:54 +0300
commit4959d8fd4967e5769c8c81bf37e18ea13f607e2b (patch)
treec8983a05de4aca907d104106206e6987d3f61706 /lib/gitlab/background_migration
parentd8f7017ab01333b51b823035b177446ec36259d8 (diff)
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/gitlab/background_migration')
-rw-r--r--lib/gitlab/background_migration/migrate_null_private_profile_to_false.rb17
1 files changed, 17 insertions, 0 deletions
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