diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /db/migrate/20201124075951_create_vulnerability_external_links.rb | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'db/migrate/20201124075951_create_vulnerability_external_links.rb')
-rw-r--r-- | db/migrate/20201124075951_create_vulnerability_external_links.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/db/migrate/20201124075951_create_vulnerability_external_links.rb b/db/migrate/20201124075951_create_vulnerability_external_links.rb new file mode 100644 index 00000000000..8200b15559b --- /dev/null +++ b/db/migrate/20201124075951_create_vulnerability_external_links.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +class CreateVulnerabilityExternalLinks < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + with_lock_retries do + create_table :vulnerability_external_issue_links, if_not_exists: true do |t| + t.timestamps_with_timezone null: false + t.references :author, null: false, index: true, foreign_key: { to_table: :users, on_delete: :nullify }, type: :bigint + t.references :vulnerability, null: false, index: true, type: :bigint + t.integer :link_type, limit: 2, null: false, default: 1 # 'created' + t.integer :external_type, limit: 2, null: false, default: 1 # 'jira' + t.text :external_project_key, null: false + t.text :external_issue_key, null: false + + t.index %i[vulnerability_id external_type external_project_key external_issue_key], + name: 'idx_vulnerability_ext_issue_links_on_vulne_id_and_ext_issue', + unique: true + t.index %i[vulnerability_id link_type], + name: 'idx_vulnerability_ext_issue_links_on_vulne_id_and_link_type', + where: 'link_type = 1', + unique: true # only one 'created' link per vulnerability is allowed + end + end + + add_concurrent_foreign_key :vulnerability_external_issue_links, :vulnerabilities, column: :vulnerability_id, on_delete: :cascade + + add_text_limit :vulnerability_external_issue_links, :external_project_key, 255 + add_text_limit :vulnerability_external_issue_links, :external_issue_key, 255 + end + + def down + with_lock_retries do + drop_table :vulnerability_external_issue_links + end + end +end |