diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
commit | 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch) | |
tree | 4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /db/migrate/20210831203408_upsert_base_work_item_types.rb | |
parent | 744144d28e3e7fddc117924fef88de5d9674fe4c (diff) |
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'db/migrate/20210831203408_upsert_base_work_item_types.rb')
-rw-r--r-- | db/migrate/20210831203408_upsert_base_work_item_types.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/db/migrate/20210831203408_upsert_base_work_item_types.rb b/db/migrate/20210831203408_upsert_base_work_item_types.rb new file mode 100644 index 00000000000..314412d8d3d --- /dev/null +++ b/db/migrate/20210831203408_upsert_base_work_item_types.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +class UpsertBaseWorkItemTypes < ActiveRecord::Migration[6.1] + module WorkItem + class Type < ActiveRecord::Base + self.table_name = 'work_item_types' + + enum base_type: { + issue: 0, + incident: 1, + test_case: 2, + requirement: 3 + } + end + end + + def up + # upsert default types + WorkItem::Type.find_or_create_by(name: 'Issue', namespace_id: nil, base_type: :issue, icon_name: 'issue-type-issue') + WorkItem::Type.find_or_create_by(name: 'Incident', namespace_id: nil, base_type: :incident, icon_name: 'issue-type-incident') + WorkItem::Type.find_or_create_by(name: 'Test Case', namespace_id: nil, base_type: :test_case, icon_name: 'issue-type-test-case') + WorkItem::Type.find_or_create_by(name: 'Requirement', namespace_id: nil, base_type: :requirement, icon_name: 'issue-type-requirements') + end + + def down + # We expect this table to be empty at the point of the up migration, + # however there is a remote possibility that issues could already be + # using one of these types, with a tight foreign constraint. + # Therefore we will not attempt to remove any data. + end +end |