Commit 92ec0ae0 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Fix migrations for older PostgreSQL versions

- Do not care about error when creating index on PostgreSQL
- Test against PostgreSQL 9.2
parent 3cfcbcf3
......@@ -52,7 +52,7 @@ stages:
.use-pg: &use-pg
services:
- postgres:latest
- postgres:9.2
- redis:alpine
.use-mysql: &use-mysql
......
---
title: Fix migration for older PostgreSQL versions
merge_request:
author:
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
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') }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment