summaryrefslogtreecommitdiff
path: root/db/migrate/20221107184542_add_new_amount_used_to_ci_namespace_monthly_usages.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-11-17 11:33:21 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-11-17 11:33:21 +0000
commit7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch)
tree5bdc2229f5198d516781f8d24eace62fc7e589e9 /db/migrate/20221107184542_add_new_amount_used_to_ci_namespace_monthly_usages.rb
parent185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff)
downloadgitlab-ce-7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0.tar.gz
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'db/migrate/20221107184542_add_new_amount_used_to_ci_namespace_monthly_usages.rb')
-rw-r--r--db/migrate/20221107184542_add_new_amount_used_to_ci_namespace_monthly_usages.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/db/migrate/20221107184542_add_new_amount_used_to_ci_namespace_monthly_usages.rb b/db/migrate/20221107184542_add_new_amount_used_to_ci_namespace_monthly_usages.rb
new file mode 100644
index 00000000000..23a5a716164
--- /dev/null
+++ b/db/migrate/20221107184542_add_new_amount_used_to_ci_namespace_monthly_usages.rb
@@ -0,0 +1,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