Commit 8ce185be authored by Stan Hu's avatar Stan Hu

Re-add template column to services table

We attempted to revert the rename of the `template` to `instance` column
in the `services` table in
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/24857 and
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/24885, but for
some installations (e.g. staging), the `template` column had been
dropped already because post-deploy migrations had finished.

We never actually shipped this change to production, but for these
environments we need to re-add the `template` column back into the table
or project creation will fail.

Note we do not do a data migration (e.g. set the `template` column to
true for rows that have a NULL `project_id`) for two reasons:

1. We don't want to insert a template by accident.
2. This rename only finished on development/staging environments.

Note that this migration happens in a post-deploy migration to ensure
`20200211152410_remove_instance_from_services.rb` gets a chance
to undo the migration first.
parent 1af54d75
# frozen_string_literal: true
class ReaddTemplateColumnToServices < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
return if column_exists? :services, :template
# The migration to drop the template column never actually shipped
# to production, so we should be okay to re-add it without worrying
# about doing a data migration. If we needed to restore the value
# of `template`, we would look for entries with `project_id IS NULL`.
add_column_with_default :services, :template, :boolean, default: false, allow_null: true
end
def down
# NOP since the column is expected to exist
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_02_11_152410) do
ActiveRecord::Schema.define(version: 2020_02_12_052620) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm"
......
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