File: 20240508000000_create_scan_execution_policy_rules.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (36 lines) | stat: -rw-r--r-- 1,123 bytes parent folder | download
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
33
34
35
36
# frozen_string_literal: true

class CreateScanExecutionPolicyRules < Gitlab::Database::Migration[2.2]
  milestone '17.1'

  UNIQUE_INDEX_NAME = "index_scan_execution_policy_rules_on_unique_policy_rule_index"
  FK_INDEX_NAME = "index_scan_execution_policy_rules_on_policy_mgmt_project_id"

  def change
    create_table :scan_execution_policy_rules do |t|
      t.references :security_policy,
        null: false,
        foreign_key: { on_delete: :cascade },
        index: false
      t.references :security_policy_management_project,
        null: false,
        foreign_key: { on_delete: :cascade, to_table: :projects },
        index: false
      t.timestamps_with_timezone null: false
      t.integer :rule_index, limit: 2, null: false
      t.integer :type, limit: 2, null: false
      t.jsonb :content, default: {}, null: false
    end

    add_index(
      :scan_execution_policy_rules,
      %i[security_policy_id rule_index],
      unique: true,
      name: UNIQUE_INDEX_NAME)

    add_index(
      :scan_execution_policy_rules,
      :security_policy_management_project_id,
      name: FK_INDEX_NAME)
  end
end