From 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 18 Feb 2021 10:34:06 +0000 Subject: Add latest changes from gitlab-org/gitlab@13-9-stable-ee --- ...2549_restore_has_external_wiki_default_value.rb | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 db/migrate/20210203092549_restore_has_external_wiki_default_value.rb (limited to 'db/migrate/20210203092549_restore_has_external_wiki_default_value.rb') diff --git a/db/migrate/20210203092549_restore_has_external_wiki_default_value.rb b/db/migrate/20210203092549_restore_has_external_wiki_default_value.rb new file mode 100644 index 00000000000..37111b370a5 --- /dev/null +++ b/db/migrate/20210203092549_restore_has_external_wiki_default_value.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +class RestoreHasExternalWikiDefaultValue < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + class TmpProject < ActiveRecord::Base + self.table_name = 'projects' + end + + # This reverts the following migration: change_column_default(:projects, :has_external_wiki, from: nil, to: false) + # We only change the column when the current default value is false + def up + # Find out the current default value + column = TmpProject.columns.find { |c| c.name == 'has_external_wiki' } + return unless column + + if column.default == 'false' + with_lock_retries do + change_column_default(:projects, :has_external_wiki, from: false, to: nil) + end + end + end + + def down + # no-op + end +end -- cgit v1.2.1