diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-30 06:10:03 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-30 06:10:03 +0000 |
commit | 27b43bd4d613cc7b8773ca0863b8d8f9b90f6d87 (patch) | |
tree | 8bc7959282786fd8acce856cfa75ad36fda5f020 /db/post_migrate | |
parent | 6b8e9712617b97b2586c90fe7855aa38e0987831 (diff) | |
download | gitlab-ce-27b43bd4d613cc7b8773ca0863b8d8f9b90f6d87.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db/post_migrate')
-rw-r--r-- | db/post_migrate/20200424043515_drop_namespaces_plan_id.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/db/post_migrate/20200424043515_drop_namespaces_plan_id.rb b/db/post_migrate/20200424043515_drop_namespaces_plan_id.rb new file mode 100644 index 00000000000..53ce13cc699 --- /dev/null +++ b/db/post_migrate/20200424043515_drop_namespaces_plan_id.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class DropNamespacesPlanId < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + with_lock_retries do # rubocop: disable Migration/WithLockRetriesWithoutDdlTransaction + remove_column :namespaces, :plan_id + end + end + + def down + unless column_exists?(:namespaces, :plan_id) + with_lock_retries do # rubocop: disable Migration/WithLockRetriesWithoutDdlTransaction + add_column :namespaces, :plan_id, :integer + end + end + + add_concurrent_index :namespaces, :plan_id + add_concurrent_foreign_key :namespaces, :plans, column: :plan_id, on_delete: :nullify + end +end |