Track created_at on CI minutes records
What does this MR do and why?
Related to: https://gitlab.com/gitlab-org/gitlab/-/issues/331707
This MR adds created_at
column for Ci::Minutes::NamespaceMonthlyUsage
and Ci::Minutes::ProjectMonthlyUsage
models.
This allows us to track exactly when the records for these 2 models are lazily created and compare the times with when
we currently reset CI minutes on our legacy tracking: namespace_statistics.shared_runners_seconds_last_reset
.
More context at https://gitlab.com/gitlab-org/gitlab/-/issues/331707#note_731715411
Database migrations
$ rails db:migrate
== 20211115145107 AddCreatedAtToNamespaceMonthlyUsages: migrating =============
-- transaction_open?()
-> 0.0000s
-- add_column(:ci_namespace_monthly_usages, :created_at, :datetime_with_timezone)
-> 0.0026s
== 20211115145107 AddCreatedAtToNamespaceMonthlyUsages: migrated (0.0486s) ====
== 20211115154103 AddCreatedAtToProjectMonthlyUsage: migrating ================
-- transaction_open?()
-> 0.0000s
-- add_column(:ci_project_monthly_usages, :created_at, :datetime_with_timezone)
-> 0.0016s
== 20211115154103 AddCreatedAtToProjectMonthlyUsage: migrated (0.0073s) =======
$ rails db:rollback STEP=2
== 20211115154103 AddCreatedAtToProjectMonthlyUsage: reverting ================
-- transaction_open?()
-> 0.0000s
-- remove_column(:ci_project_monthly_usages, :created_at)
-> 0.0029s
== 20211115154103 AddCreatedAtToProjectMonthlyUsage: reverted (0.0350s) =======
== 20211115145107 AddCreatedAtToNamespaceMonthlyUsages: reverting =============
-- transaction_open?()
-> 0.0000s
-- remove_column(:ci_namespace_monthly_usages, :created_at)
-> 0.0015s
== 20211115145107 AddCreatedAtToNamespaceMonthlyUsages: reverted (0.0056s) ====
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Fabio Pitino