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/migrate/20211126204445_add_task_to_work_item_types.rb')
-rw-r--r--db/migrate/20211126204445_add_task_to_work_item_types.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/db/migrate/20211126204445_add_task_to_work_item_types.rb b/db/migrate/20211126204445_add_task_to_work_item_types.rb
new file mode 100644
index 00000000000..875c2272c6d
--- /dev/null
+++ b/db/migrate/20211126204445_add_task_to_work_item_types.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+class AddTaskToWorkItemTypes < Gitlab::Database::Migration[1.0]
+ TASK_ENUM_VALUE = 4
+
+ class WorkItemType < ActiveRecord::Base
+ self.inheritance_column = :_type_disabled
+ self.table_name = 'work_item_types'
+
+ validates :name, uniqueness: { case_sensitive: false, scope: [:namespace_id] }
+ end
+
+ def up
+ # New instances will not run this migration and add this type via fixtures
+ # checking if record exists mostly because migration specs will run all migrations
+ # and that will conflict with the preloaded base work item types
+ task_work_item = WorkItemType.find_by(name: 'Task', namespace_id: nil)
+
+ if task_work_item
+ say('Task item record exist, skipping creation')
+ else
+ WorkItemType.create(name: 'Task', namespace_id: nil, base_type: TASK_ENUM_VALUE, icon_name: 'issue-type-task')
+ end
+ end
+
+ def down
+ # There's the remote possibility that issues could already be
+ # using this issue type, with a tight foreign constraint.
+ # Therefore we will not attempt to remove any data.
+ end
+end