19 lines
961 B
Ruby
19 lines
961 B
Ruby
# frozen_string_literal: true
|
|
|
|
class CreateVulnerabilityUserMentions < ActiveRecord::Migration[6.0]
|
|
DOWNTIME = false
|
|
|
|
def change
|
|
create_table :vulnerability_user_mentions do |t|
|
|
t.references :vulnerability, type: :bigint, index: false, null: false, foreign_key: { on_delete: :cascade }
|
|
t.references :note, type: :integer,
|
|
index: { where: 'note_id IS NOT NULL', unique: true }, null: true, foreign_key: { on_delete: :cascade }
|
|
t.integer :mentioned_users_ids, array: true
|
|
t.integer :mentioned_projects_ids, array: true
|
|
t.integer :mentioned_groups_ids, array: true
|
|
end
|
|
|
|
add_index :vulnerability_user_mentions, [:vulnerability_id], where: 'note_id is null', unique: true, name: 'index_vulns_user_mentions_on_vulnerability_id'
|
|
add_index :vulnerability_user_mentions, [:vulnerability_id, :note_id], unique: true, name: 'index_vulns_user_mentions_on_vulnerability_id_and_note_id'
|
|
end
|
|
end
|