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:
Diffstat (limited to 'lib/gitlab/background_migration/backfill_user_preferences_with_defaults.rb')
-rw-r--r--lib/gitlab/background_migration/backfill_user_preferences_with_defaults.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/gitlab/background_migration/backfill_user_preferences_with_defaults.rb b/lib/gitlab/background_migration/backfill_user_preferences_with_defaults.rb
new file mode 100644
index 00000000000..2fba6e66d48
--- /dev/null
+++ b/lib/gitlab/background_migration/backfill_user_preferences_with_defaults.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module BackgroundMigration
+ # Backfills the user_preferences table columns with their default values
+ class BackfillUserPreferencesWithDefaults < BatchedMigrationJob
+ operation_name :backfill_user_preferences_with_defaults
+ feature_category :user_profile
+
+ def perform
+ each_sub_batch do |sub_batch|
+ connection.transaction do
+ sub_batch.where(tab_width: nil).update_all(tab_width: 8)
+ sub_batch.where(time_display_relative: nil).update_all(time_display_relative: true)
+ sub_batch.where(render_whitespace_in_code: nil).update_all(render_whitespace_in_code: false)
+ end
+ end
+ end
+ end
+ end
+end