diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 16:37:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 16:37:47 +0300 |
commit | aee0a117a889461ce8ced6fcf73207fe017f1d99 (patch) | |
tree | 891d9ef189227a8445d83f35c1b0fc99573f4380 /db/migrate/20211126204445_add_task_to_work_item_types.rb | |
parent | 8d46af3258650d305f53b819eabf7ab18d22f59e (diff) |
Add latest changes from gitlab-org/gitlab@14-6-stable-eev14.6.0-rc42
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.rb | 31 |
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 |