summaryrefslogtreecommitdiff
path: root/db/migrate/20170309173138_create_protected_tags.rb
blob: 4684c9964c496eaf74532e6478c1f57e61e189d9 (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
# rubocop:disable Migration/Timestamps
class CreateProtectedTags < ActiveRecord::Migration
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  GITLAB_ACCESS_MASTER = 40

  def change
    create_table :protected_tags do |t|
      t.integer :project_id, null: false
      t.string :name, null: false
      t.timestamps null: false
    end

    add_index :protected_tags, :project_id

    create_table :protected_tag_create_access_levels do |t|
      t.references :protected_tag, index: { name: "index_protected_tag_create_access" }, foreign_key: true, null: false
      t.integer :access_level, default: GITLAB_ACCESS_MASTER, null: true
      t.references :user, foreign_key: true, index: true
      t.integer :group_id
      t.timestamps null: false
    end

    add_foreign_key :protected_tag_create_access_levels, :namespaces, column: :group_id # rubocop: disable Migration/AddConcurrentForeignKey
  end
end