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

20220113111440_schedule_fix_incorrect_max_seats_used.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f39b026bd7701e6467047acc655b38a535177009 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

class ScheduleFixIncorrectMaxSeatsUsed < Gitlab::Database::Migration[1.0]
  DOWNTIME = false
  TMP_IDX_NAME = 'tmp_gitlab_subscriptions_max_seats_used_migration'

  disable_ddl_transaction!

  def up
    add_concurrent_index :gitlab_subscriptions, :id, where: "start_date >= '2021-08-02' AND start_date <= '2021-11-20' AND max_seats_used != 0 AND max_seats_used > seats_in_use AND max_seats_used > seats", name: TMP_IDX_NAME

    return unless Gitlab.com?

    migrate_in(1.hour, 'FixIncorrectMaxSeatsUsed')
  end

  def down
    remove_concurrent_index_by_name :gitlab_subscriptions, TMP_IDX_NAME
  end
end