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

20191023152913_add_default_and_free_plans.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4f5f800038620a7835bb2cd0f9e8e8e0c5172a47 (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
27
28
29
# frozen_string_literal: true

class AddDefaultAndFreePlans < ActiveRecord::Migration[5.2]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  class Plan < ApplicationRecord
  end

  def up
    plan_names.each do |plan_name|
      Plan.create_with(title: plan_name.titleize).find_or_create_by(name: plan_name)
    end
  end

  def down
    Plan.where(name: plan_names).delete_all
  end

  private

  def plan_names
    [
      ('free' if Gitlab.com?),
      'default'
    ].compact
  end
end