Commit d3bf0160 authored by Shinya Maeda's avatar Shinya Maeda

Remove access_level index from runner. Add protected on ci_pipelines. Add...

Remove access_level index from runner. Add protected on ci_pipelines. Add protected index on ci_builds.
parent a2cde284
...@@ -12,7 +12,8 @@ module Ci ...@@ -12,7 +12,8 @@ module Ci
tag: tag?, tag: tag?,
trigger_requests: Array(trigger_request), trigger_requests: Array(trigger_request),
user: current_user, user: current_user,
pipeline_schedule: schedule pipeline_schedule: schedule,
protected: project.protected_for?(ref)
) )
result = validate(current_user, result = validate(current_user,
......
class AddProtectedToCiPipelines < ActiveRecord::Migration
DOWNTIME = false
def change
add_column :ci_pipelines, :protected, :boolean
end
end
class AddIndexOnCiRunnersAccessLevel < ActiveRecord::Migration class AddIndexOnCiBuildsProtected < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
DOWNTIME = false DOWNTIME = false
...@@ -6,10 +6,10 @@ class AddIndexOnCiRunnersAccessLevel < ActiveRecord::Migration ...@@ -6,10 +6,10 @@ class AddIndexOnCiRunnersAccessLevel < ActiveRecord::Migration
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_concurrent_index :ci_runners, :access_level add_concurrent_index :ci_builds, :protected
end end
def down def down
remove_concurrent_index :ci_runners, :access_level if index_exists?(:ci_runners, :access_level) remove_concurrent_index :ci_builds, :protected if index_exists?(:ci_builds, :protected)
end end
end end
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170824162758) do ActiveRecord::Schema.define(version: 20170830125940) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
...@@ -255,6 +255,7 @@ ActiveRecord::Schema.define(version: 20170824162758) do ...@@ -255,6 +255,7 @@ ActiveRecord::Schema.define(version: 20170824162758) do
add_index "ci_builds", ["commit_id", "type", "name", "ref"], name: "index_ci_builds_on_commit_id_and_type_and_name_and_ref", using: :btree add_index "ci_builds", ["commit_id", "type", "name", "ref"], name: "index_ci_builds_on_commit_id_and_type_and_name_and_ref", using: :btree
add_index "ci_builds", ["commit_id", "type", "ref"], name: "index_ci_builds_on_commit_id_and_type_and_ref", using: :btree add_index "ci_builds", ["commit_id", "type", "ref"], name: "index_ci_builds_on_commit_id_and_type_and_ref", using: :btree
add_index "ci_builds", ["project_id"], name: "index_ci_builds_on_project_id", using: :btree add_index "ci_builds", ["project_id"], name: "index_ci_builds_on_project_id", using: :btree
add_index "ci_builds", ["protected"], name: "index_ci_builds_on_protected", using: :btree
add_index "ci_builds", ["runner_id"], name: "index_ci_builds_on_runner_id", using: :btree add_index "ci_builds", ["runner_id"], name: "index_ci_builds_on_runner_id", using: :btree
add_index "ci_builds", ["stage_id"], name: "index_ci_builds_on_stage_id", using: :btree add_index "ci_builds", ["stage_id"], name: "index_ci_builds_on_stage_id", using: :btree
add_index "ci_builds", ["status", "type", "runner_id"], name: "index_ci_builds_on_status_and_type_and_runner_id", using: :btree add_index "ci_builds", ["status", "type", "runner_id"], name: "index_ci_builds_on_status_and_type_and_runner_id", using: :btree
...@@ -337,6 +338,7 @@ ActiveRecord::Schema.define(version: 20170824162758) do ...@@ -337,6 +338,7 @@ ActiveRecord::Schema.define(version: 20170824162758) do
t.integer "auto_canceled_by_id" t.integer "auto_canceled_by_id"
t.integer "pipeline_schedule_id" t.integer "pipeline_schedule_id"
t.integer "source" t.integer "source"
t.boolean "protected"
end end
add_index "ci_pipelines", ["auto_canceled_by_id"], name: "index_ci_pipelines_on_auto_canceled_by_id", using: :btree add_index "ci_pipelines", ["auto_canceled_by_id"], name: "index_ci_pipelines_on_auto_canceled_by_id", using: :btree
...@@ -375,7 +377,6 @@ ActiveRecord::Schema.define(version: 20170824162758) do ...@@ -375,7 +377,6 @@ ActiveRecord::Schema.define(version: 20170824162758) do
t.integer "access_level", default: 0, null: false t.integer "access_level", default: 0, null: false
end end
add_index "ci_runners", ["access_level"], name: "index_ci_runners_on_access_level", using: :btree
add_index "ci_runners", ["contacted_at"], name: "index_ci_runners_on_contacted_at", using: :btree add_index "ci_runners", ["contacted_at"], name: "index_ci_runners_on_contacted_at", using: :btree
add_index "ci_runners", ["is_shared"], name: "index_ci_runners_on_is_shared", using: :btree add_index "ci_runners", ["is_shared"], name: "index_ci_runners_on_is_shared", using: :btree
add_index "ci_runners", ["locked"], name: "index_ci_runners_on_locked", using: :btree add_index "ci_runners", ["locked"], name: "index_ci_runners_on_locked", using: :btree
......
...@@ -398,6 +398,7 @@ describe Ci::CreatePipelineService do ...@@ -398,6 +398,7 @@ describe Ci::CreatePipelineService do
it 'creates a pipeline' do it 'creates a pipeline' do
expect(execute_service).to be_persisted expect(execute_service).to be_persisted
expect(Ci::Pipeline.count).to eq(1) expect(Ci::Pipeline.count).to eq(1)
expect(Ci::Pipeline.last).to be_protected
end end
end end
...@@ -473,6 +474,7 @@ describe Ci::CreatePipelineService do ...@@ -473,6 +474,7 @@ describe Ci::CreatePipelineService do
expect(execute_service(trigger_request: trigger_request)) expect(execute_service(trigger_request: trigger_request))
.to be_persisted .to be_persisted
expect(Ci::Pipeline.count).to eq(1) expect(Ci::Pipeline.count).to eq(1)
expect(Ci::Pipeline.last).not_to be_protected
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment