summaryrefslogtreecommitdiff
path: root/db/migrate/20200721052853_create_dast_scanner_profile.rb
blob: 0dc0012d83745fd7b4a59259a53427440204c6ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# frozen_string_literal: true

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

  DOWNTIME = false

  disable_ddl_transaction!

  def up
    unless table_exists?(:dast_scanner_profiles)
      with_lock_retries do
        create_table :dast_scanner_profiles do |t|
          t.timestamps_with_timezone null: false
          t.references :project, null: false, index: false, foreign_key: { on_delete: :cascade }, type: :integer
          t.integer :spider_timeout, limit: 2
          t.integer :target_timeout, limit: 2
          t.text :name, null: false
          t.index [:project_id, :name], unique: true
        end
      end
    end

    add_text_limit(:dast_scanner_profiles, :name, 255)
  end

  def down
    with_lock_retries do
      drop_table :dast_scanner_profiles
    end
  end
end