diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-05-23 00:33:08 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-05-23 01:08:51 +0300 |
commit | 92ec0ae0a7997aa841106432a319be51b2d446a0 (patch) | |
tree | d72f5edaf450bcb326d6c233db8d326bcfd6e5b9 /db/post_migrate | |
parent | 3cfcbcf35badfdb21244f7f16c8640cd83b49205 (diff) |
Fix migrations for older PostgreSQL versions
- Do not care about error when creating index on PostgreSQL
- Test against PostgreSQL 9.2
Diffstat (limited to 'db/post_migrate')
-rw-r--r-- | db/post_migrate/20170503004427_update_retried_for_ci_build.rb (renamed from db/post_migrate/20170503004427_upate_retried_for_ci_build.rb) | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/db/post_migrate/20170503004427_upate_retried_for_ci_build.rb b/db/post_migrate/20170503004427_update_retried_for_ci_build.rb index 738e46b9207..705e11ed47d 100644 --- a/db/post_migrate/20170503004427_upate_retried_for_ci_build.rb +++ b/db/post_migrate/20170503004427_update_retried_for_ci_build.rb @@ -1,4 +1,4 @@ -class UpateRetriedForCiBuild < ActiveRecord::Migration +class UpdateRetriedForCiBuild < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = false @@ -54,13 +54,15 @@ class UpateRetriedForCiBuild < ActiveRecord::Migration def with_temporary_partial_index if Gitlab::Database.postgresql? - execute 'CREATE INDEX CONCURRENTLY IF NOT EXISTS index_for_ci_builds_retried_migration ON ci_builds (id) WHERE retried IS NULL;' + unless index_exists?(:ci_builds, name: :index_for_ci_builds_retried_migration) + execute 'CREATE INDEX CONCURRENTLY index_for_ci_builds_retried_migration ON ci_builds (id) WHERE retried IS NULL;' + end end yield - if Gitlab::Database.postgresql? - execute 'DROP INDEX CONCURRENTLY IF EXISTS index_for_ci_builds_retried_migration' + if Gitlab::Database.postgresql? && index_exists?(:ci_builds, name: :index_for_ci_builds_retried_migration) + execute 'DROP INDEX CONCURRENTLY index_for_ci_builds_retried_migration' end end end |