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

20200902135542_update_package_max_file_size_plan_limits.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0ba8f12f89eb52ed9c5b6ff7cc7e609fe085f94c (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# frozen_string_literal: true

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

  DOWNTIME = false

  def up
    # this is intended to be a no-op for GitLab.com
    # 5GB is the value for these columns as of 2020-09-02
    if Gitlab.com?
      update_all_plan_limits('conan_max_file_size', 5.gigabytes)
      update_all_plan_limits('maven_max_file_size', 5.gigabytes)
      update_all_plan_limits('npm_max_file_size', 5.gigabytes)
      update_all_plan_limits('nuget_max_file_size', 5.gigabytes)
      update_all_plan_limits('pypi_max_file_size', 5.gigabytes)
    else
      update_all_plan_limits('conan_max_file_size', 3.gigabytes)
      update_all_plan_limits('maven_max_file_size', 3.gigabytes)
      update_all_plan_limits('npm_max_file_size', 500.megabytes)
      update_all_plan_limits('nuget_max_file_size', 500.megabytes)
      update_all_plan_limits('pypi_max_file_size', 3.gigabytes)
    end
  end

  def down
    update_all_plan_limits('conan_max_file_size', 50.megabytes)
    update_all_plan_limits('maven_max_file_size', 50.megabytes)
    update_all_plan_limits('npm_max_file_size', 50.megabytes)
    update_all_plan_limits('nuget_max_file_size', 50.megabytes)
    update_all_plan_limits('pypi_max_file_size', 50.megabytes)
  end

  private

  def update_all_plan_limits(limit_name, limit_value)
    limit_name_quoted = quote_column_name(limit_name)
    limit_value_quoted = quote(limit_value)

    execute <<~SQL
      UPDATE plan_limits
      SET #{limit_name_quoted} = #{limit_value_quoted};
    SQL
  end
end