# frozen_string_literal: true

class CreateVulnerabilityFindingLinks < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  disable_ddl_transaction!

  def up
    create_table :vulnerability_finding_links, if_not_exists: true do |t|
      t.timestamps_with_timezone null: false
      t.references :vulnerability_occurrence, index: { name: 'finding_links_on_vulnerability_occurrence_id' }, null: false, foreign_key: { on_delete: :cascade }
      t.text :name, limit: 255
      t.text :url, limit: 2048, null: false
    end

    add_text_limit :vulnerability_finding_links, :name, 255
    add_text_limit :vulnerability_finding_links, :url, 2048
  end

  def down
    drop_table :vulnerability_finding_links
  end
end