Draft: Add add_on_metrics field to HistoricalData
What does this MR do and why?
Relates to #551159
This MR adds a new add_on_metrics field to the HistoricalData table. This is needed in preparation for Track add_on_metrics in HistoricalData (#551173) which is where we will begin saving these metrics to this field as part of the HistoricalData.track! method.
This is part of the epic Add Duo Add-on Metrics to Export File for Offli... (&18245) to eventually allow tracking add-on metrics over time for offline cloud licensing customers as part of the license usage export process.
The data structure and schema validation must match our add-on metrics generation process for online cloud customers, as both the seat link sync and emailed license usage exports will save records to the same LicenseSeatLink table in CustomersDot.
Example add-on metrics format:
[
{
add_on_type: 'duo_enterprise',
assigned_seats: 5,
purchased_seats: 10
},
{
add_on_type: 'duo_core',
assigned_seats: 0,
purchased_seats: 10
}
]
Database changes
Up
valerieburton@vburton--20240209-3D393 gitlab % bundle exec rails db:migrate
main: == [advisory_lock_connection] object_id: 139620, pg_backend_pid: 12541
main: == 20250710200913 AddAddOnMetricsToHistoricalData: migrating ==================
main: -- add_column(:historical_data, :add_on_metrics, :jsonb)
main: -> 0.0242s
main: == 20250710200913 AddAddOnMetricsToHistoricalData: migrated (0.0285s) =========
main: == [advisory_lock_connection] object_id: 139620, pg_backend_pid: 12541
ci: == [advisory_lock_connection] object_id: 139620, pg_backend_pid: 12542
ci: == 20250710200913 AddAddOnMetricsToHistoricalData: migrating ==================
ci: -- add_column(:historical_data, :add_on_metrics, :jsonb)
ci: -> 0.0020s
ci: == 20250710200913 AddAddOnMetricsToHistoricalData: migrated (0.0077s) =========
ci: == [advisory_lock_connection] object_id: 139620, pg_backend_pid: 12542
Down
valerieburton@vburton--20240209-3D393 gitlab % VERSION=20250710200913 bundle exec rails db:migrate:down:main
main: == [advisory_lock_connection] object_id: 139320, pg_backend_pid: 27872
main: == 20250710200913 AddAddOnMetricsToHistoricalData: reverting ==================
main: -- remove_column(:historical_data, :add_on_metrics, :jsonb)
main: -> 0.0212s
main: == 20250710200913 AddAddOnMetricsToHistoricalData: reverted (0.0261s) =========
main: == [advisory_lock_connection] object_id: 139320, pg_backend_pid: 27872
valerieburton@vburton--20240209-3D393 gitlab % VERSION=20250710200913 bundle exec rails db:migrate:down:ci
ci: == [advisory_lock_connection] object_id: 139320, pg_backend_pid: 27996
ci: == 20250710200913 AddAddOnMetricsToHistoricalData: reverting ==================
ci: -- remove_column(:historical_data, :add_on_metrics, :jsonb)
ci: -> 0.0292s
ci: == 20250710200913 AddAddOnMetricsToHistoricalData: reverted (0.0586s) =========
ci: == [advisory_lock_connection] object_id: 139320, pg_backend_pid: 27996
Screenshots or screen recordings
N/A (backend changes only)
How to set up and validate locally
Regression Testing
- Pull down this branch and run
bundle exec rails db:migrateto apply the new column - Log into your GDK as an admin and upload a Premium or Ultimate license
- Open Rails console and run the following worker:
HistoricalDataWorker.new.perform
- Verify the worker runs successfully and a new
HistoricalDatarecord is created - Check
HistoricalData.lastand verifyadd_on_metricsisnil - Visit
admin/subscriptionand click onExport license usage file - Verify a CSV file is created without errors and the file contents listed in this documentation are generated as expected. Add-on metrics should not be present yet.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.