diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-18 15:06:03 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-18 15:06:03 +0300 |
commit | 16d9f66e9651d35b52e5a167789befe7b861292c (patch) | |
tree | 38ffe73aeffa5bc8ceaa3357db302edce6d874f6 /db/migrate/20191115091425_create_vulnerability_issue_links.rb | |
parent | 5333cb6c7c960aac58af40c898c87d050d829383 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db/migrate/20191115091425_create_vulnerability_issue_links.rb')
-rw-r--r-- | db/migrate/20191115091425_create_vulnerability_issue_links.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/db/migrate/20191115091425_create_vulnerability_issue_links.rb b/db/migrate/20191115091425_create_vulnerability_issue_links.rb new file mode 100644 index 00000000000..8398b6357c4 --- /dev/null +++ b/db/migrate/20191115091425_create_vulnerability_issue_links.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class CreateVulnerabilityIssueLinks < ActiveRecord::Migration[5.2] + DOWNTIME = false + + def change + create_table :vulnerability_issue_links do |t| + # index: false because idx_vulnerability_issue_links_on_vulnerability_id_and_issue_id refers the same column + t.references :vulnerability, null: false, index: false, foreign_key: { on_delete: :cascade } + # index: true is implied + t.references :issue, null: false, foreign_key: { on_delete: :cascade } + t.integer 'link_type', limit: 2, null: false, default: 1 # 'related' + t.index %i[vulnerability_id issue_id], + name: 'idx_vulnerability_issue_links_on_vulnerability_id_and_issue_id', + unique: true # only one link (and of only one type) is allowed + t.index %i[vulnerability_id link_type], + name: 'idx_vulnerability_issue_links_on_vulnerability_id_and_link_type', + where: 'link_type = 2', + unique: true # only one 'created' link per vulnerability is allowed + t.timestamps_with_timezone + end + end +end |