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 'db/post_migrate/20240105121755_add_participants_widget_definition_to_work_item_types.rb')
-rw-r--r--db/post_migrate/20240105121755_add_participants_widget_definition_to_work_item_types.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/db/post_migrate/20240105121755_add_participants_widget_definition_to_work_item_types.rb b/db/post_migrate/20240105121755_add_participants_widget_definition_to_work_item_types.rb
new file mode 100644
index 00000000000..7313e14c44e
--- /dev/null
+++ b/db/post_migrate/20240105121755_add_participants_widget_definition_to_work_item_types.rb
@@ -0,0 +1,41 @@
+# frozen_string_literal: true
+
+class AddParticipantsWidgetDefinitionToWorkItemTypes < Gitlab::Database::Migration[2.2]
+ milestone '16.9'
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ WIDGET_NAME = 'Participants'
+ WIDGET_ENUM_VALUE = 20
+
+ def up
+ widgets = []
+
+ work_item_types = define_batchable_model('work_item_types')
+ work_item_types.each_batch do |work_item_types|
+ work_item_types.each do |type|
+ widgets << {
+ work_item_type_id: type.id,
+ name: WIDGET_NAME,
+ widget_type: WIDGET_ENUM_VALUE
+ }
+ end
+ end
+
+ return if widgets.empty?
+
+ work_item_widget_definitions.upsert_all(
+ widgets,
+ unique_by: :index_work_item_widget_definitions_on_default_witype_and_name
+ )
+ end
+
+ def down
+ work_item_widget_definitions.where(name: WIDGET_NAME).delete_all
+ end
+
+ private
+
+ def work_item_widget_definitions
+ define_batchable_model('work_item_widget_definitions')
+ end
+end