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

20230105170414_rename_amount_used_column_on_ci_namespace_monthly_usages_table.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ff59b1e598709e1219156864154ce7ee4880b53f (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
# frozen_string_literal: true

class RenameAmountUsedColumnOnCiNamespaceMonthlyUsagesTable < Gitlab::Database::Migration[2.1]
  enable_lock_retries!

  TRIGGER_NAME = 'sync_namespaces_amount_used_columns'
  def up
    rename_column :ci_namespace_monthly_usages, :amount_used, :tmp_amount_used
    rename_column :ci_namespace_monthly_usages, :new_amount_used, :amount_used
    rename_column :ci_namespace_monthly_usages, :tmp_amount_used, :new_amount_used

    remove_rename_triggers(:ci_namespace_monthly_usages, TRIGGER_NAME)
    install_rename_triggers(:ci_namespace_monthly_usages, :amount_used, :new_amount_used, trigger_name: TRIGGER_NAME)
  end

  def down
    rename_column :ci_namespace_monthly_usages, :amount_used, :tmp_amount_used
    rename_column :ci_namespace_monthly_usages, :new_amount_used, :amount_used
    rename_column :ci_namespace_monthly_usages, :tmp_amount_used, :new_amount_used

    remove_rename_triggers(:ci_namespace_monthly_usages, TRIGGER_NAME)
    install_rename_triggers(:ci_namespace_monthly_usages, :amount_used, :new_amount_used, trigger_name: TRIGGER_NAME)
  end
end