summaryrefslogtreecommitdiff
path: root/db/post_migrate
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-30 06:10:03 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-30 06:10:03 +0000
commit27b43bd4d613cc7b8773ca0863b8d8f9b90f6d87 (patch)
tree8bc7959282786fd8acce856cfa75ad36fda5f020 /db/post_migrate
parent6b8e9712617b97b2586c90fe7855aa38e0987831 (diff)
downloadgitlab-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.rb26
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