Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20200113151354_remove_creations_in_gitlab_subscription_histories.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 39ca5124b324a74e049f37d0f50ead4d61b016c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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