Backfill application_settings product_analytics_data_collector_host
What does this MR do and why?
Relates to: #389490 (closed)
jitsu_host
and collector_host
should be stored separately. However, currently we only store jitsu_host
and calculate the collector_host
based on jitsu_host
.
Recently, we added a new product_analytics_data_collector_host
to application_settings
table to store the above-mentioned collector host.
This current MR is for filling this new column. Note that this feature is behind a feature flag and there should be only a handful of records to be updated.
Running the migration locally produced the following output.
gitlab git:(backfill-product-analytics-application-setting-for-collector-host) ✗ VERSION=20230308112121 bundle exec rails db:migrate:up:main
main: == 20230308112121 BackfillProductAnalyticsDataCollectorHost: migrating ========
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("UPDATE application_settings\nSET product_analytics_data_collector_host = regexp_replace(jitsu_host, '://(.+?\\.)', '://collector.', 'g')\nWHERE jitsu_host IS NOT NULL AND id BETWEEN 1 AND 1;\n")
main: -> 0.0051s
Backfill application_settings product_analytics_data_collector_host
main: == 20230308112121 BackfillProductAnalyticsDataCollectorHost: migrated (0.6365s)
Query plan (without batching)
Time: 31.685 ms
- planning: 3.170 ms
- execution: 28.515 ms
- I/O read: 22.233 ms
- I/O write: 0.000 ms
Shared buffers:
- hits: 82 (~656.00 KiB) from the buffer pool
- reads: 17 (~136.00 KiB) from the OS file cache, including disk I/O
- dirtied: 5 (~40.00 KiB)
- writes: 0
How to set up and validate locally
- Have a record with jitsu host
ApplicationSetting.first.update(jitsu_host: "https://configurator.testing.my-product-analytics.com", product_analytics_enabled: true)
- Run migration
bVERSION=20230308112121 bundle exec rails db:migrate:up:main
- Check
product_analytics_data_collector_host
ApplicationSetting.first.product_analytics_data_collector_host #should be "https://collector.testing.my-product-analytics.com"
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 Halil Coban