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/20221111142921_add_hierarchy_restrictions.rb')
-rw-r--r--db/migrate/20221111142921_add_hierarchy_restrictions.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/db/migrate/20221111142921_add_hierarchy_restrictions.rb b/db/migrate/20221111142921_add_hierarchy_restrictions.rb
new file mode 100644
index 00000000000..dd80de04969
--- /dev/null
+++ b/db/migrate/20221111142921_add_hierarchy_restrictions.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddHierarchyRestrictions < Gitlab::Database::Migration[2.0]
+ UNIQUE_INDEX_NAME = 'index_work_item_hierarchy_restrictions_on_parent_and_child'
+
+ def up
+ create_table :work_item_hierarchy_restrictions do |t|
+ t.references :parent_type, index: true, null: false,
+ foreign_key: { on_delete: :cascade, to_table: :work_item_types }
+ t.references :child_type, index: true, null: false,
+ foreign_key: { on_delete: :cascade, to_table: :work_item_types }
+ t.integer :maximum_depth, limit: 2
+
+ t.index [:parent_type_id, :child_type_id], unique: true, name: UNIQUE_INDEX_NAME
+ end
+ end
+
+ def down
+ drop_table :work_item_hierarchy_restrictions
+ end
+end