Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Hotfix for SQL migration failing when migrating from 1.2.4 to 1.3.0 (#1699)

Martin Peeterse55611ad2d60
diff --git a/manager/src/main/resources/org/openremote/manager/setup/database/V20250217_01__KeepExistingWidgetConfig.sql b/manager/src/main/resources/org/openremote/manager/setup/database/V20250217_01__KeepExistingWidgetConfig.sql
index 52c56ebcf..849da54d7 100644
--- a/manager/src/main/resources/org/openremote/manager/setup/database/V20250217_01__KeepExistingWidgetConfig.sql
+++ b/manager/src/main/resources/org/openremote/manager/setup/database/V20250217_01__KeepExistingWidgetConfig.sql
@@ -1,32 +1,19 @@
-/*
-* Set existing widgets configs to match their pre-update behavior.
-*/
-
-WITH json_data AS (
- SELECT
- id,
+UPDATE dashboard
+SET template = jsonb_set(
template,
- jsonb_set(
- template,
- '{widgets}',
- (
- SELECT jsonb_agg(
- jsonb_set(
- widget,
- '{widgetConfig,allOfType}',
- CASE
- WHEN (widget ->> 'widgetTypeId') = 'map' THEN 'true'::jsonb
- WHEN (widget ->> 'widgetTypeId') = 'table' THEN 'false'::jsonb
- ELSE widget -> 'widgetConfig' -> 'allOfType'
- END
- )
- )
- FROM jsonb_array_elements(template -> 'widgets') AS widget
- )
- ) AS updated_json
- FROM dashboard
+ '{widgets}',
+ (
+ SELECT jsonb_agg(
+ CASE
+ WHEN widget->>'widgetTypeId' = 'map' THEN
+ jsonb_set(widget, '{widgetConfig,allOfType}', 'true'::jsonb)
+ WHEN widget->>'widgetTypeId' = 'table' THEN
+ jsonb_set(widget, '{widgetConfig,allOfType}', 'false'::jsonb)
+ ELSE
+ widget -- Leave non-map/table widgets unchanged
+ END
+ )
+ FROM jsonb_array_elements(template->'widgets') widget
+ )
)
-UPDATE dashboard
-SET template = json_data.updated_json
-FROM json_data
-WHERE dashboard.id = json_data.id;
\ No newline at end of file
+WHERE template->'widgets' IS NOT NULL;