| 1 | -- Issues became work items (g1t #57), and the dataset `issues` is |
| 2 | -- `work_items` now (packages/contracts/src/datasets.ts). A dashboard's |
| 3 | -- tiles are kept in its Yjs document, which no dashboard has yet (the kind |
| 4 | -- is not built: kinds/index.ts); a workspace's dashboard templates keep |
| 5 | -- theirs as JSON (`{ tiles: [{ query: { dataset } }] }`), rewritten here. |
| 6 | UPDATE folio_templates |
| 7 | SET body = json_set(body, '$.tiles', ( |
| 8 | SELECT json_group_array(json(tile)) FROM ( |
| 9 | SELECT CASE WHEN json_extract(t.value, '$.query.dataset') = 'issues' |
| 10 | THEN json_set(t.value, '$.query.dataset', 'work_items') |
| 11 | ELSE t.value END AS tile |
| 12 | FROM json_each(folio_templates.body, '$.tiles') t |
| 13 | ORDER BY t.key |
| 14 | ) |
| 15 | )) |
| 16 | WHERE kind = 'dashboard' AND json_valid(body) AND json_type(body, '$.tiles') = 'array' |
| 17 | AND EXISTS (SELECT 1 FROM json_each(folio_templates.body, '$.tiles') t WHERE json_extract(t.value, '$.query.dataset') = 'issues'); |