diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /db/migrate/20201108134919_add_finding_fingerprint_table.rb | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) | |
download | gitlab-ce-859a6fb938bb9ee2a317c46dfa4fcc1af49608f0.tar.gz |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'db/migrate/20201108134919_add_finding_fingerprint_table.rb')
-rw-r--r-- | db/migrate/20201108134919_add_finding_fingerprint_table.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/db/migrate/20201108134919_add_finding_fingerprint_table.rb b/db/migrate/20201108134919_add_finding_fingerprint_table.rb new file mode 100644 index 00000000000..dd8ffe8e8aa --- /dev/null +++ b/db/migrate/20201108134919_add_finding_fingerprint_table.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +class AddFindingFingerprintTable < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + FINGERPRINT_IDX = :idx_vuln_fingerprints_on_occurrences_id_and_fingerprint + UNIQ_IDX = :idx_vuln_fingerprints_uniqueness + + def up + with_lock_retries do + create_table :vulnerability_finding_fingerprints do |t| + t.references :finding, + index: true, + null: false, + foreign_key: { to_table: :vulnerability_occurrences, column: :finding_id, on_delete: :cascade } + + t.timestamps_with_timezone null: false + + t.integer :algorithm_type, null: false + t.binary :fingerprint_sha256, null: false + + t.index %i[finding_id fingerprint_sha256], + name: FINGERPRINT_IDX, + unique: true # only one link should exist between occurrence and the fingerprint + + t.index %i[finding_id algorithm_type fingerprint_sha256], + name: UNIQ_IDX, + unique: true # these should be unique + end + end + end + + def down + with_lock_retries do + drop_table :vulnerability_finding_fingerprints + end + end +end |