summaryrefslogtreecommitdiff
path: root/db/migrate/20221221171239_rename_amount_used_column.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-18 19:00:14 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-18 19:00:14 +0000
commit05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch)
tree11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /db/migrate/20221221171239_rename_amount_used_column.rb
parentec73467c23693d0db63a797d10194da9e72a74af (diff)
downloadgitlab-ce-05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2.tar.gz
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'db/migrate/20221221171239_rename_amount_used_column.rb')
-rw-r--r--db/migrate/20221221171239_rename_amount_used_column.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/db/migrate/20221221171239_rename_amount_used_column.rb b/db/migrate/20221221171239_rename_amount_used_column.rb
new file mode 100644
index 00000000000..f25407a85af
--- /dev/null
+++ b/db/migrate/20221221171239_rename_amount_used_column.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class RenameAmountUsedColumn < Gitlab::Database::Migration[2.1]
+ TRIGGER_NAME = 'sync_projects_amount_used_columns'
+ def up
+ rename_column :ci_project_monthly_usages, :amount_used, :tmp_amount_used
+ rename_column :ci_project_monthly_usages, :new_amount_used, :amount_used
+ rename_column :ci_project_monthly_usages, :tmp_amount_used, :new_amount_used
+
+ remove_rename_triggers(:ci_project_monthly_usages, TRIGGER_NAME)
+ install_rename_triggers(:ci_project_monthly_usages, :amount_used, :new_amount_used, trigger_name: TRIGGER_NAME)
+ end
+
+ def down
+ rename_column :ci_project_monthly_usages, :amount_used, :tmp_amount_used
+ rename_column :ci_project_monthly_usages, :new_amount_used, :amount_used
+ rename_column :ci_project_monthly_usages, :tmp_amount_used, :new_amount_used
+
+ remove_rename_triggers(:ci_project_monthly_usages, TRIGGER_NAME)
+ install_rename_triggers(:ci_project_monthly_usages, :amount_used, :new_amount_used, trigger_name: TRIGGER_NAME)
+ end
+end