diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2024-01-17 18:10:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2024-01-17 18:10:08 +0300 |
commit | 78a5f872de316860ccd7a983c10805bf6c6b771c (patch) | |
tree | 29c394a4114d012cf9dcef37037e1992ef15105d /db/post_migrate/20240105121755_add_participants_widget_definition_to_work_item_types.rb | |
parent | 14c3ebc6364f7d5eb31cbf2e66a79ec574e88b70 (diff) |
Add latest changes from gitlab-org/gitlab@master
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.rb | 41 |
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 |