summaryrefslogtreecommitdiff
path: root/db/migrate/20191030152934_move_limits_from_plans.rb
blob: 020a028f648019e22c0352ffb2406109785781fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

class MoveLimitsFromPlans < ActiveRecord::Migration[5.2]
  DOWNTIME = false

  def up
    execute <<~SQL
      INSERT INTO plan_limits (plan_id, ci_active_pipelines, ci_pipeline_size, ci_active_jobs)
      SELECT id, COALESCE(active_pipelines_limit, 0), COALESCE(pipeline_size_limit, 0), COALESCE(active_jobs_limit, 0)
      FROM plans
    SQL
  end

  def down
    execute 'DELETE FROM plan_limits'
  end
end