diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2017-11-30 18:05:17 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-12-03 14:05:23 +0300 |
commit | 592e0877f470efbb224043a6f887265afa070e0b (patch) | |
tree | 5dbf790023a6930ec98e02297eb94e98f882d01e /db | |
parent | ab02bd69425fe17e65717bed91e99b62e11c0e74 (diff) |
Add unique index on job_id and file_type
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20171130145523_uniqueness_contraint_job_artifact_file_type.rb | 16 | ||||
-rw-r--r-- | db/schema.rb | 3 |
2 files changed, 18 insertions, 1 deletions
diff --git a/db/migrate/20171130145523_uniqueness_contraint_job_artifact_file_type.rb b/db/migrate/20171130145523_uniqueness_contraint_job_artifact_file_type.rb new file mode 100644 index 00000000000..7ecbac8a81d --- /dev/null +++ b/db/migrate/20171130145523_uniqueness_contraint_job_artifact_file_type.rb @@ -0,0 +1,16 @@ +class UniquenessContraintJobArtifactFileType < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :ci_job_artifacts, [:job_id, :file_type], unique: true + end + + def down + remove_concurrent_index :ci_job_artifacts, [:job_id, :file_type] + end +end diff --git a/db/schema.rb b/db/schema.rb index 0f71463acd8..3ec183f1c05 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: 20171124150326) do +ActiveRecord::Schema.define(version: 20171130145523) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -330,6 +330,7 @@ ActiveRecord::Schema.define(version: 20171124150326) do end add_index "ci_job_artifacts", ["file_type"], name: "index_ci_job_artifacts_on_file_type", using: :btree + add_index "ci_job_artifacts", ["job_id", "file_type"], name: "index_ci_job_artifacts_on_job_id_and_file_type", unique: true, using: :btree add_index "ci_job_artifacts", ["job_id"], name: "index_ci_job_artifacts_on_job_id", using: :btree add_index "ci_job_artifacts", ["project_id"], name: "index_ci_job_artifacts_on_project_id", using: :btree |