summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-04-25 21:03:35 +0900
committerKamil TrzciƄski <ayufan@ayufan.eu>2018-05-03 10:48:33 +0200
commit332d3d0ef5215c2a363c99c90fb7d31af90a0a5a (patch)
treecfc81fba2f92c7cc419d389f98533a8c6c39306e
parent3248ca0467a4bd816f281db1b30ca83df2865edd (diff)
downloadgitlab-ce-332d3d0ef5215c2a363c99c90fb7d31af90a0a5a.tar.gz
Change column name to iid_per_project. Add index to project_id and iid
-rw-r--r--db/migrate/20180424160449_add_pipeline_iid_to_ci_pipelines.rb4
-rw-r--r--db/migrate/20180425205249_add_index_constraints_to_pipeline_iid.rb15
-rw-r--r--db/schema.rb5
3 files changed, 20 insertions, 4 deletions
diff --git a/db/migrate/20180424160449_add_pipeline_iid_to_ci_pipelines.rb b/db/migrate/20180424160449_add_pipeline_iid_to_ci_pipelines.rb
index d732116e9ce..128377e1c9d 100644
--- a/db/migrate/20180424160449_add_pipeline_iid_to_ci_pipelines.rb
+++ b/db/migrate/20180424160449_add_pipeline_iid_to_ci_pipelines.rb
@@ -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
diff --git a/db/migrate/20180425205249_add_index_constraints_to_pipeline_iid.rb b/db/migrate/20180425205249_add_index_constraints_to_pipeline_iid.rb
new file mode 100644
index 00000000000..7daa7197b7c
--- /dev/null
+++ b/db/migrate/20180425205249_add_index_constraints_to_pipeline_iid.rb
@@ -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
diff --git a/db/schema.rb b/db/schema.rb
index d4bc075eb2e..af838e109b2 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -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