Skip to content

Fix amount_used column precision on ci_namespace_monthly_usages table

What does this MR do and why?

Parent issue: https://gitlab.com/gitlab-org/gitlab/-/issues/382386
This MR is one of 2 to address the above issue. Other MR can be found here.

Adding following migrations:
20230105170414 Rename amount used column on ci namespace monthly usages table
20230105172120 Sync new amount used with amount used on ci namespace monthly usages table
20230105180002 Remove new amount used column on ci namespace monthly usages
\

Migrations logs:

Migration: 20230105170414 Rename amount used column on ci namespace monthly usages table
on MAIN database:
UP

rake db:migrate:up:main VERSION=20230105170414
main: == 20230105170414 RenameAmountUsedColumnOnCiNamespaceMonthlyUsagesTable: migrating 
main: -- rename_column(:ci_namespace_monthly_usages, :amount_used, :tmp_amount_used)
main:    -> 0.1433s
main: -- rename_column(:ci_namespace_monthly_usages, :new_amount_used, :amount_used)
main:    -> 0.0017s
main: -- rename_column(:ci_namespace_monthly_usages, :tmp_amount_used, :new_amount_used)
main:    -> 0.0016s
main: == 20230105170414 RenameAmountUsedColumnOnCiNamespaceMonthlyUsagesTable: migrated (0.1531s) 

DOWN

 ✗ rake db:migrate:down:main VERSION=20230105170414
main: == 20230105170414 RenameAmountUsedColumnOnCiNamespaceMonthlyUsagesTable: reverting 
main: -- rename_column(:ci_namespace_monthly_usages, :amount_used, :tmp_amount_used)
main:    -> 0.0708s
main: -- rename_column(:ci_namespace_monthly_usages, :new_amount_used, :amount_used)
main:    -> 0.0020s
main: -- rename_column(:ci_namespace_monthly_usages, :tmp_amount_used, :new_amount_used)
main:    -> 0.0017s
main: == 20230105170414 RenameAmountUsedColumnOnCiNamespaceMonthlyUsagesTable: reverted (0.0792s) 

on CI database:
UP

✗ rake db:migrate:up:ci VERSION=20230105170414
ci: == 20230105170414 RenameAmountUsedColumnOnCiNamespaceMonthlyUsagesTable: migrating 
ci: -- rename_column(:ci_namespace_monthly_usages, :amount_used, :tmp_amount_used)
ci:    -> 0.0726s
ci: -- rename_column(:ci_namespace_monthly_usages, :new_amount_used, :amount_used)
ci:    -> 0.0020s
ci: -- rename_column(:ci_namespace_monthly_usages, :tmp_amount_used, :new_amount_used)
ci:    -> 0.0018s
ci: == 20230105170414 RenameAmountUsedColumnOnCiNamespaceMonthlyUsagesTable: migrated (0.0888s) 

DOWN

✗ rake db:migrate:down:ci VERSION=20230105170414
ci: == 20230105170414 RenameAmountUsedColumnOnCiNamespaceMonthlyUsagesTable: reverting 
ci: -- rename_column(:ci_namespace_monthly_usages, :amount_used, :tmp_amount_used)
ci:    -> 0.1140s
ci: -- rename_column(:ci_namespace_monthly_usages, :new_amount_used, :amount_used)
ci:    -> 0.0035s
ci: -- rename_column(:ci_namespace_monthly_usages, :tmp_amount_used, :new_amount_used)
ci:    -> 0.0042s
ci: == 20230105170414 RenameAmountUsedColumnOnCiNamespaceMonthlyUsagesTable: reverted (0.1411s) 

Post-deployment migration: 20230105172120 Sync new amount used with amount used on ci namespace monthly usages table
on CI database:
UP

✗ rake db:migrate:up:ci VERSION=20230105172120
ci: == 20230105172120 SyncNewAmountUsedWithAmountUsedOnCiNamespaceMonthlyUsagesTable: migrating 
ci: == 20230105172120 SyncNewAmountUsedWithAmountUsedOnCiNamespaceMonthlyUsagesTable: migrated (0.0113s) 

DOWN

✗ rake db:migrate:down:ci VERSION=20230105172120
ci: == 20230105172120 SyncNewAmountUsedWithAmountUsedOnCiNamespaceMonthlyUsagesTable: reverting 
ci: == 20230105172120 SyncNewAmountUsedWithAmountUsedOnCiNamespaceMonthlyUsagesTable: reverted (0.0339s) 

on MAIN database:
UP

✗ rake db:migrate:up:main VERSION=20230105172120
main: == 20230105172120 SyncNewAmountUsedWithAmountUsedOnCiNamespaceMonthlyUsagesTable: migrating 
main: -- The migration is skipped since it modifies the schemas: [:gitlab_ci].
main: -- This database can only apply migrations in one of the following schemas: [:gitlab_main, :gitlab_shared, :gitlab_internal, :gitlab_pm].
main: == 20230105172120 SyncNewAmountUsedWithAmountUsedOnCiNamespaceMonthlyUsagesTable: migrated (0.0144s) 

DOWN

✗ rake db:migrate:down:main VERSION=20230105172120
main: == 20230105172120 SyncNewAmountUsedWithAmountUsedOnCiNamespaceMonthlyUsagesTable: reverting 
main: -- The migration is skipped since it modifies the schemas: [:gitlab_ci].
main: -- This database can only apply migrations in one of the following schemas: [:gitlab_main, :gitlab_shared, :gitlab_internal, :gitlab_pm].
main: == 20230105172120 SyncNewAmountUsedWithAmountUsedOnCiNamespaceMonthlyUsagesTable: reverted (0.0013s)

Post-deployment migration: 20230105180002 Remove new amount used column on ci namespace monthly usages
on CI database:
UP

 ✗ rake db:migrate:up:ci VERSION=20230105180002
ci: == 20230105180002 RemoveNewAmountUsedColumnOnCiNamespaceMonthlyUsages: migrating 
ci: -- remove_column(:ci_namespace_monthly_usages, :new_amount_used)
ci:    -> 0.0010s
ci: == 20230105180002 RemoveNewAmountUsedColumnOnCiNamespaceMonthlyUsages: migrated (0.0174s) 

DOWN

✗ rake db:migrate:down:ci VERSION=20230105180002
ci: == 20230105180002 RemoveNewAmountUsedColumnOnCiNamespaceMonthlyUsages: reverting 
ci: -- column_exists?(:ci_namespace_monthly_usages, :new_amount_used)
ci:    -> 0.1184s
ci: -- add_column(:ci_namespace_monthly_usages, :new_amount_used, :decimal, {:default=>0.0, :precision=>18, :scale=>2, :null=>false})
ci:    -> 0.0029s
ci: == 20230105180002 RemoveNewAmountUsedColumnOnCiNamespaceMonthlyUsages: reverted (0.1366s)

on MAIN database:
UP

✗ rake db:migrate:up:main VERSION=20230105180002   
main: == 20230105180002 RemoveNewAmountUsedColumnOnCiNamespaceMonthlyUsages: migrating 
main: -- remove_column(:ci_namespace_monthly_usages, :new_amount_used)
main:    -> 0.0005s
main: == 20230105180002 RemoveNewAmountUsedColumnOnCiNamespaceMonthlyUsages: migrated (0.0039s) 

DOWN

rake db:migrate:down:main VERSION=20230105180002              
main: == 20230105180002 RemoveNewAmountUsedColumnOnCiNamespaceMonthlyUsages: reverting 
main: -- column_exists?(:ci_namespace_monthly_usages, :new_amount_used)
main:    -> 0.1107s
main: -- add_column(:ci_namespace_monthly_usages, :new_amount_used, :decimal, {:default=>0.0, :precision=>18, :scale=>2, :null=>false})
main:    -> 0.0025s
main: == 20230105180002 RemoveNewAmountUsedColumnOnCiNamespaceMonthlyUsages: reverted (0.1190s) 

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Kasia Misirli

Merge request reports