From 1a416a42f1c1b876ecd96687e41696bc915cc2c2 Mon Sep 17 00:00:00 2001 From: James Edwards-Jones Date: Wed, 15 Mar 2017 22:26:48 +0000 Subject: Database migrations for protected tags Added schema.rb for protected tags --- db/migrate/20170309173138_create_protected_tags.rb | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 db/migrate/20170309173138_create_protected_tags.rb (limited to 'db/migrate/20170309173138_create_protected_tags.rb') diff --git a/db/migrate/20170309173138_create_protected_tags.rb b/db/migrate/20170309173138_create_protected_tags.rb new file mode 100644 index 00000000000..c69ef970410 --- /dev/null +++ b/db/migrate/20170309173138_create_protected_tags.rb @@ -0,0 +1,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 -- cgit v1.2.1 From b5fce1d5ac87546e8f31fb0ef6f6c4d514670198 Mon Sep 17 00:00:00 2001 From: James Edwards-Jones Date: Fri, 31 Mar 2017 17:56:26 +0100 Subject: =?UTF-8?q?Removed=20unnecessary=20table=20=E2=80=98protected=5Fta?= =?UTF-8?q?g=5Fmerge=5Faccess=5Flevels=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed timestamps on protected_tags --- db/migrate/20170309173138_create_protected_tags.rb | 23 ++++++---------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'db/migrate/20170309173138_create_protected_tags.rb') diff --git a/db/migrate/20170309173138_create_protected_tags.rb b/db/migrate/20170309173138_create_protected_tags.rb index c69ef970410..00794529143 100644 --- a/db/migrate/20170309173138_create_protected_tags.rb +++ b/db/migrate/20170309173138_create_protected_tags.rb @@ -4,36 +4,25 @@ class CreateProtectedTags < ActiveRecord::Migration # Set this constant to true if this migration requires downtime. DOWNTIME = false - GitlabAccessMaster = 40 + GITLAB_ACCESS_MASTER = 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 + t.timestamps null: false 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.integer :access_level, default: GITLAB_ACCESS_MASTER, null: true + t.references :user, foreign_key: true, index: true + t.integer :group_id#TODO: Should this have an index? Doesn't appear in brances #, index: true 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 + add_foreign_key :protected_tag_push_access_levels, :namespaces, column: :group_id # rubocop: disable Migration/AddConcurrentForeignKey end end -- cgit v1.2.1 From 07d7d8e65905a39164b63f55eccdcea8f10f5d14 Mon Sep 17 00:00:00 2001 From: James Edwards-Jones Date: Tue, 4 Apr 2017 03:37:22 +0100 Subject: Renamed ProtectedTag push_access_levels to create_access_levels --- db/migrate/20170309173138_create_protected_tags.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'db/migrate/20170309173138_create_protected_tags.rb') diff --git a/db/migrate/20170309173138_create_protected_tags.rb b/db/migrate/20170309173138_create_protected_tags.rb index 00794529143..538f28479c7 100644 --- a/db/migrate/20170309173138_create_protected_tags.rb +++ b/db/migrate/20170309173138_create_protected_tags.rb @@ -15,14 +15,14 @@ class CreateProtectedTags < ActiveRecord::Migration add_index :protected_tags, :project_id - 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 + 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#TODO: Should this have an index? Doesn't appear in brances #, index: true + t.integer :group_id t.timestamps null: false end - add_foreign_key :protected_tag_push_access_levels, :namespaces, column: :group_id # rubocop: disable Migration/AddConcurrentForeignKey + add_foreign_key :protected_tag_create_access_levels, :namespaces, column: :group_id # rubocop: disable Migration/AddConcurrentForeignKey end end -- cgit v1.2.1 From f16377e7dc762462817dd0b34e36811c55988b10 Mon Sep 17 00:00:00 2001 From: James Edwards-Jones Date: Wed, 5 Apr 2017 18:59:46 +0100 Subject: Protected Tags backend review changes Added changelog --- db/migrate/20170309173138_create_protected_tags.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'db/migrate/20170309173138_create_protected_tags.rb') diff --git a/db/migrate/20170309173138_create_protected_tags.rb b/db/migrate/20170309173138_create_protected_tags.rb index 538f28479c7..796f3c90344 100644 --- a/db/migrate/20170309173138_create_protected_tags.rb +++ b/db/migrate/20170309173138_create_protected_tags.rb @@ -1,7 +1,6 @@ class CreateProtectedTags < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers - # Set this constant to true if this migration requires downtime. DOWNTIME = false GITLAB_ACCESS_MASTER = 40 -- cgit v1.2.1