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

20221107184542_add_new_amount_used_to_ci_namespace_monthly_usages.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 23a5a71616425c3467f0bea1327fef9976734ca0 (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 AddNewAmountUsedToCiNamespaceMonthlyUsages < Gitlab::Database::Migration[2.0]
  TABLE = :ci_namespace_monthly_usages
  OLD_COLUMN = :amount_used
  NEW_COLUMN = :new_amount_used
  TRIGGER_NAME = 'sync_namespaces_amount_used_columns'

  disable_ddl_transaction!

  def up
    check_trigger_permissions!(TABLE)

    add_column(TABLE, NEW_COLUMN, :decimal, default: 0.0, precision: 18, scale: 4, null: false, if_not_exists: true)

    install_rename_triggers(TABLE, OLD_COLUMN, NEW_COLUMN, trigger_name: TRIGGER_NAME)
  end

  def down
    remove_rename_triggers(TABLE, TRIGGER_NAME)

    remove_column(TABLE, NEW_COLUMN)
  end
end