Change column name to iid_per_project. Add index to project_id and iid

This commit is contained in:
Shinya Maeda 2018-04-25 21:03:35 +09:00 committed by Kamil Trzciński
parent 3248ca0467
commit 332d3d0ef5
3 changed files with 20 additions and 4 deletions

View File

@ -6,10 +6,10 @@ class AddPipelineIidToCiPipelines < ActiveRecord::Migration
disable_ddl_transaction!
def up
add_column :ci_pipelines, :iid, :integer
add_column :ci_pipelines, :iid_per_project, :integer
end
def down
remove_column :ci_pipelines, :iid, :integer
remove_column :ci_pipelines, :iid_per_project, :integer
end
end

View File

@ -0,0 +1,15 @@
class AddIndexConstraintsToPipelineIid < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :ci_pipelines, [:project_id, :iid_per_project], unique: true, where: 'iid_per_project IS NOT NULL'
end
def down
remove_concurrent_index :ci_pipelines, [:project_id, :iid_per_project]
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20180425131009) do
ActiveRecord::Schema.define(version: 20180425205249) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -434,11 +434,12 @@ ActiveRecord::Schema.define(version: 20180425131009) do
t.integer "config_source"
t.boolean "protected"
t.integer "failure_reason"
t.integer "iid"
t.integer "iid_per_project"
end
add_index "ci_pipelines", ["auto_canceled_by_id"], name: "index_ci_pipelines_on_auto_canceled_by_id", using: :btree
add_index "ci_pipelines", ["pipeline_schedule_id"], name: "index_ci_pipelines_on_pipeline_schedule_id", using: :btree
add_index "ci_pipelines", ["project_id", "iid_per_project"], name: "index_ci_pipelines_on_project_id_and_iid_per_project", unique: true, where: "(iid_per_project IS NOT NULL)", using: :btree
add_index "ci_pipelines", ["project_id", "ref", "status", "id"], name: "index_ci_pipelines_on_project_id_and_ref_and_status_and_id", using: :btree
add_index "ci_pipelines", ["project_id", "sha"], name: "index_ci_pipelines_on_project_id_and_sha", using: :btree
add_index "ci_pipelines", ["project_id"], name: "index_ci_pipelines_on_project_id", using: :btree