summaryrefslogtreecommitdiff
path: root/db/migrate/20170309173138_create_protected_tags.rb
blob: c69ef9704109325b590151def17d7c2f35ae15fb (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
33
34
35
36
37
38
39
class CreateProtectedTags < ActiveRecord::Migration
  include Gitlab::Database::MigrationHelpers

  # Set this constant to true if this migration requires downtime.
  DOWNTIME = false

  GitlabAccessMaster = 40

  def change
    create_table :protected_tags do |t|
      t.integer :project_id, null: false
      t.string :name, null: false
      t.string :timestamps #TODO: `null: false`? Missing from protected_branches
    end

    add_index :protected_tags, :project_id

    create_table :protected_tag_merge_access_levels do |t|
      t.references :protected_tag, index: { name: "index_protected_tag_merge_access" }, foreign_key: true, null: false

      t.integer :access_level, default: GitlabAccessMaster, null: true #TODO: was false, check schema
      t.integer :group_id #TODO: check why group/user id missing from CE
      t.integer :user_id
      t.timestamps null: false
    end

    create_table :protected_tag_push_access_levels do |t|
      t.references :protected_tag, index: { name: "index_protected_tag_push_access" }, foreign_key: true, null: false
      t.integer :access_level, default: GitlabAccessMaster, null: true #TODO: was false, check schema
      t.integer :group_id
      t.integer :user_id
      t.timestamps null: false
    end

    #TODO: These had rubocop set to disable Migration/AddConcurrentForeignKey
    # add_foreign_key :protected_tag_merge_access_levels, :namespaces, column: :group_id 
    # add_foreign_key :protected_tag_push_access_levels, :namespaces, column: :group_id
  end
end