Commit 22a8c7e4 authored by Tiger Watson's avatar Tiger Watson

Merge branch '216970-add-instance-to-service-if-missing' into 'master'

Add instance column to services table if it's missing

Closes #216970

See merge request gitlab-org/gitlab!31631
parents 485ac579 4e7d06da
---
title: Add instance column to services table if it's missing
merge_request: 31631
author:
type: fixed
# frozen_string_literal: true
class AddMissingInstanceToServicess < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
# This is a corrective migration to keep the instance column.
# Upgrade from 12.7 to 12.9 removes the instance column as it was first added
# in the normal migration and then removed in the post migration.
#
# 12.8 removed the instance column in a post deployment migration https://gitlab.com/gitlab-org/gitlab/-/merge_requests/24885
# 12.9 added the instance column in a normal migration https://gitlab.com/gitlab-org/gitlab/-/merge_requests/25714
#
# rubocop:disable Migration/AddColumnWithDefault
# rubocop:disable Migration/UpdateLargeTable
def up
unless column_exists?(:services, :instance)
add_column_with_default(:services, :instance, :boolean, default: false)
end
end
# rubocop:enable Migration/AddColumnWithDefault
# rubocop:enable Migration/UpdateLargeTable
def down
# Does not apply
end
end
# frozen_string_literal: true
class AddMissingIndexToServiceUniqueInstancePerType < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
# This is a corrective migration to keep the index on instance column.
# Upgrade from 12.7 to 12.9 removes the instance column as it was first added
# in the normal migration and then removed in the post migration.
#
# 12.8 removed the instance column in a post deployment migration https://gitlab.com/gitlab-org/gitlab/-/merge_requests/24885
# 12.9 added the instance column in a normal migration https://gitlab.com/gitlab-org/gitlab/-/merge_requests/25714
def up
unless index_exists_by_name?(:services, 'index_services_on_type_and_instance')
add_concurrent_index(:services, [:type, :instance], unique: true, where: 'instance IS TRUE')
end
end
def down
# Does not apply
end
end
......@@ -13792,6 +13792,8 @@ COPY "schema_migrations" (version) FROM STDIN;
20200511121610
20200511121620
20200511145545
20200511162057
20200511162115
20200512085150
\.
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