Minor fix broken 1.9.8 migrations (#23487)

* chore: fix duplicate migrations from 1.9.8

* fix: psql update query
This commit is contained in:
Teddy 2025-09-22 15:13:25 +02:00 committed by GitHub
parent 0d0bd5a632
commit 71f993a2fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 24 additions and 5 deletions

View File

@ -0,0 +1,7 @@
-- If you upgraded to 1.9.8 with the initial migration and then upgraded to 1.9.9
-- `'profileData', pdts.json` `pdts.json` will have the profileData in the json field
-- you will hence have performed the same migration again. This brings the json
-- `profileData`field back to the original state.
UPDATE profiler_data_time_series
SET json = JSON_SET(json, '$.profileData', json->'$.profileData.profileData')
WHERE json->>'$.profileData.profileData' IS NOT NULL;

View File

@ -0,0 +1,7 @@
-- If you upgraded to 1.9.8 with the initial migration and then upgraded to 1.9.9
-- `'profileData', pdts.json` `pdts.json` will have the profileData in the json field
-- you will hence have performed the same migration again. This brings the json
-- `profileData`field back to the original state.
UPDATE profiler_data_time_series
SET json = jsonb_set(json::jsonb, '{profileData}', json::jsonb->'profileData'->'profileData')::json
WHERE json->'profileData'->>'profileData' IS NOT NULL;

View File

@ -28,7 +28,8 @@ SET pdts.json = JSON_OBJECT(
'profileData', pdts.json,
'profileType', 'table'
)
WHERE pdts.extension = 'table.tableProfile';
WHERE pdts.extension = 'table.tableProfile'
AND pdts.json->>'$.profileData' IS NULL;
-- Migrate system profiles (direct match)
UPDATE profiler_data_time_series pdts
@ -45,7 +46,8 @@ SET pdts.json = JSON_OBJECT(
'profileData', pdts.json,
'profileType', 'system'
)
WHERE pdts.extension = 'table.systemProfile';
WHERE pdts.extension = 'table.systemProfile'
AND pdts.json->>'$.profileData' IS NULL;
-- Migrate column profiles using temporary mapping table for better performance
-- Create temporary mapping table to extract table hash from column hash

View File

@ -33,7 +33,8 @@ SET json = jsonb_build_object(
)
FROM table_entity te
WHERE pdts.entityFQNHash = te.fqnHash
AND pdts.extension = 'table.tableProfile';
AND pdts.extension = 'table.tableProfile'
AND pdts.json->>'profileData' IS NULL;
-- Migrate system profiles (direct match)
UPDATE profiler_data_time_series pdts
@ -51,7 +52,8 @@ SET json = jsonb_build_object(
)
FROM table_entity te
WHERE pdts.entityFQNHash = te.fqnHash
AND pdts.extension = 'table.systemProfile';
AND pdts.extension = 'table.systemProfile'
AND pdts.json->>'profileData' IS NULL;
-- Migrate column profiles using temporary mapping table for better performance
-- Use UNLOGGED table for memory-like performance (no WAL writes)
@ -95,7 +97,8 @@ SET json = jsonb_build_object(
FROM column_to_table_mapping ctm
INNER JOIN table_entity te ON ctm.table_hash = te.fqnHash
WHERE pdts.entityFQNHash = ctm.column_hash
AND pdts.extension = 'table.columnProfile';
AND pdts.extension = 'table.columnProfile'
AND pdts.json->>'profileData' IS NULL;
-- Clean up temporary table
DROP TABLE IF EXISTS column_to_table_mapping;