summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-17 00:09:00 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-17 00:09:00 +0000
commitefb0c7f501e4a8883796b5acfdc584e2720febba (patch)
treea5870a33d1154a555a46b293aac42dbb4197b31d /db
parent727b1a890c8e44440414c59611e9ead34d6edc93 (diff)
downloadgitlab-ce-efb0c7f501e4a8883796b5acfdc584e2720febba.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20200113151354_remove_creations_in_gitlab_subscription_histories.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/db/post_migrate/20200113151354_remove_creations_in_gitlab_subscription_histories.rb b/db/post_migrate/20200113151354_remove_creations_in_gitlab_subscription_histories.rb
new file mode 100644
index 00000000000..39ca5124b32
--- /dev/null
+++ b/db/post_migrate/20200113151354_remove_creations_in_gitlab_subscription_histories.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class RemoveCreationsInGitlabSubscriptionHistories < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+ GITLAB_SUBSCRIPTION_CREATED = 0
+
+ def up
+ return unless Gitlab.com?
+
+ delete_sql = "DELETE FROM gitlab_subscription_histories WHERE change_type=#{GITLAB_SUBSCRIPTION_CREATED} RETURNING *"
+
+ records = execute(delete_sql)
+
+ logger = Gitlab::BackgroundMigration::Logger.build
+ records.to_a.each do |record|
+ logger.info record.as_json.merge(message: "gitlab_subscription_histories with change_type=0 was deleted")
+ end
+ end
+
+ def down
+ # There's no way to restore, and the data is useless
+ # all the data to be deleted in case needed https://gitlab.com/gitlab-org/gitlab/uploads/7409379b0ed658624f5d33202b5668a1/gitlab_subscription_histories_change_type_0.sql.txt
+ end
+end