Fix migrations for older PostgreSQL versions
- Do not care about error when creating index on PostgreSQL - Test against PostgreSQL 9.2
This commit is contained in:
parent
3cfcbcf35b
commit
92ec0ae0a7
4 changed files with 13 additions and 7 deletions
|
@ -52,7 +52,7 @@ stages:
|
|||
|
||||
.use-pg: &use-pg
|
||||
services:
|
||||
- postgres:latest
|
||||
- postgres:9.2
|
||||
- redis:alpine
|
||||
|
||||
.use-mysql: &use-mysql
|
||||
|
|
4
changelogs/unreleased/fix-migration-for-postgres.yml
Normal file
4
changelogs/unreleased/fix-migration-for-postgres.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
title: Fix migration for older PostgreSQL versions
|
||||
merge_request:
|
||||
author:
|
|
@ -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
|
|
@ -1,7 +1,7 @@
|
|||
require 'spec_helper'
|
||||
require Rails.root.join('db', 'post_migrate', '20170503004427_upate_retried_for_ci_build.rb')
|
||||
require Rails.root.join('db', 'post_migrate', '20170503004427_update_retried_for_ci_build.rb')
|
||||
|
||||
describe UpateRetriedForCiBuild, truncate: true do
|
||||
describe UpdateRetriedForCiBuild, truncate: true do
|
||||
let(:pipeline) { create(:ci_pipeline) }
|
||||
let!(:build_old) { create(:ci_build, pipeline: pipeline, name: 'test') }
|
||||
let!(:build_new) { create(:ci_build, pipeline: pipeline, name: 'test') }
|
Loading…
Reference in a new issue