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_vs_code_settings_version.rb')
-rw-r--r--lib/gitlab/background_migration/backfill_vs_code_settings_version.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/gitlab/background_migration/backfill_vs_code_settings_version.rb b/lib/gitlab/background_migration/backfill_vs_code_settings_version.rb
new file mode 100644
index 00000000000..83dbf5f3852
--- /dev/null
+++ b/lib/gitlab/background_migration/backfill_vs_code_settings_version.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module BackgroundMigration
+ class BackfillVsCodeSettingsVersion < BatchedMigrationJob
+ feature_category :web_ide
+ operation_name :backfill_vs_code_settings_version
+ scope_to ->(relation) { relation.where(version: [nil, 0]) }
+
+ class VsCodeSetting < ApplicationRecord
+ DEFAULT_SETTING_VERSIONS = {
+ 'settings' => 2,
+ 'extensions' => 6,
+ 'globalState' => 1,
+ 'keybindings' => 2,
+ 'snippets' => 1,
+ 'machines' => 1,
+ 'tasks' => 1,
+ 'profiles' => 2
+ }.freeze
+
+ self.table_name = 'vs_code_settings'
+ end
+
+ def perform
+ each_sub_batch do |sub_batch|
+ vs_code_settings = sub_batch.map do |vs_code_setting|
+ version = VsCodeSetting::DEFAULT_SETTING_VERSIONS[vs_code_setting.setting_type]
+
+ vs_code_setting.attributes.merge(version: version)
+ end
+
+ VsCodeSetting.upsert_all(vs_code_settings)
+ end
+ end
+ end
+ end
+end