summaryrefslogtreecommitdiff
path: root/db/migrate/20210526190553_insert_ci_daily_pipeline_schedule_triggers_plan_limits.rb
blob: fe0969c15fbd8032075f8daa0d4229b907e383ca (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
25
26
# frozen_string_literal: true

class InsertCiDailyPipelineScheduleTriggersPlanLimits < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  EVERY_5_MINUTES = (1.day.in_minutes / 5).to_i
  EVERY_HOUR = 1.day.in_hours.to_i

  def up
    return unless Gitlab.com?

    create_or_update_plan_limit('ci_daily_pipeline_schedule_triggers', 'free', EVERY_HOUR)
    create_or_update_plan_limit('ci_daily_pipeline_schedule_triggers', 'bronze', EVERY_5_MINUTES)
    create_or_update_plan_limit('ci_daily_pipeline_schedule_triggers', 'silver', EVERY_5_MINUTES)
    create_or_update_plan_limit('ci_daily_pipeline_schedule_triggers', 'gold', EVERY_5_MINUTES)
  end

  def down
    return unless Gitlab.com?

    create_or_update_plan_limit('ci_daily_pipeline_schedule_triggers', 'free', 0)
    create_or_update_plan_limit('ci_daily_pipeline_schedule_triggers', 'bronze', 0)
    create_or_update_plan_limit('ci_daily_pipeline_schedule_triggers', 'silver', 0)
    create_or_update_plan_limit('ci_daily_pipeline_schedule_triggers', 'gold', 0)
  end
end