 ORDER BY project_rid, widget->'id') AS nw
 WHERE p.widget_uid = nw.widget_uid;
 
+-- Convert grid column / row to layout
 UPDATE project_widgets
 SET widget = jsonb_set(widget, '{"layout"}', jsonb_build_object(
     'x', split_part(widget->>'gridcolumn', ' ', 1)::int - 1,

    OR widget->'gridcolumn' IS NOT NULL
    OR widget->'gridrow' IS NOT NULL
    OR widget->'width' IS NOT NULL
    OR widget->'position' IS NOT NULL;

))
WHERE widget->'gridcolumn' is NOT NULL;

-- Convert width only to layout
UPDATE project_widgets
SET widget = jsonb_set(widget, '{"layout"}', jsonb_build_object(
    'x', 0,
