Add last_assigned_users_refreshed_at column
What does this MR do and why?
This MR adds last_assigned_users_refreshed_at
column to the subscription_add_on_purchases
table.
This column will be used to track when was last time the user assignment for the add_on_purchase
was refreshed.
Currently, the user assignments are refreshed by RefreshUserAssignmentsWorker, whenever Group/Project links are destroyed. Reference MR: !130947 (comment 1552609051)
This MR is first part to creating a the CronJob to refresh the assigned users of AddOnPurchase
periodically, so that we have eventual consistency, if any removal of ineligible assigned seats was skipped/missed for some reason. Reference MR comment: !130751 (comment 1546453539)
Update: Draft MR for 2nd part: !132419 (merged)
Migration
# up
bin/rails db:migrate:main
main: == [advisory_lock_connection] object_id: 227380, pg_backend_pid: 33281
main: == 20230920153321 AddLastAssignedUsersRefreshedAtToSubscriptionAddOnPurchases: migrating
main: -- add_column(:subscription_add_on_purchases, :last_assigned_users_refreshed_at, :datetime_with_timezone)
main: -> 0.0030s
main: == 20230920153321 AddLastAssignedUsersRefreshedAtToSubscriptionAddOnPurchases: migrated (0.0143s)
main: == [advisory_lock_connection] object_id: 227380, pg_backend_pid: 33281
# down
bin/rails db:rollback:main
main: == [advisory_lock_connection] object_id: 227220, pg_backend_pid: 32891
main: == 20230920153321 AddLastAssignedUsersRefreshedAtToSubscriptionAddOnPurchases: reverting
main: -- remove_column(:subscription_add_on_purchases, :last_assigned_users_refreshed_at, :datetime_with_timezone)
main: -> 0.0020s
main: == 20230920153321 AddLastAssignedUsersRefreshedAtToSubscriptionAddOnPurchases: reverted (0.0087s)
main: == [advisory_lock_connection] object_id: 227220, pg_backend_pid: 32891
Table size
- The table
subscription_add_on_purchases
should be empty in production as we haven't released the feature yet. - There are
52
records as of2023-09-20 22:35
on staging:
Loading production environment (Rails 7.0.6)
[ gstg ] production> GitlabSubscriptions::AddOnPurchase.count
=> 52
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.
Related to #424758