Download this file
| 1 | ALTER TABLE chat_projects ADD COLUMN autonomy text; |
| 2 | ALTER TABLE chat_projects ADD COLUMN autonomy_owner text; |
| 3 | ALTER TABLE chat_projects ADD COLUMN autonomy_revision integer; |
| 4 | ALTER TABLE chat_steps ADD COLUMN base_checks_sha text; |
| 5 | -- Historical notebook entries have no composer reference. Preserve their text |
| 6 | -- and IDs, but do not certify the old model-written attribution as person words. |
| 7 | UPDATE chat_notebooks |
| 8 | SET entries = ( |
| 9 | SELECT json_group_array(json(CASE |
| 10 | WHEN json_extract(value, '$.source') = 'person' |
| 11 | THEN json_set(value, '$.source', 'own') ELSE value END)) |
| 12 | FROM json_each(chat_notebooks.entries) |
| 13 | ), revision = coalesce(revision, 0) + 1 |
| 14 | WHERE CASE WHEN json_valid(entries) THEN json_type(entries) = 'array' ELSE 0 END |
| 15 | AND NOT EXISTS (SELECT 1 FROM json_each(chat_notebooks.entries) WHERE type <> 'object') |
| 16 | AND EXISTS (SELECT 1 FROM json_each(chat_notebooks.entries) WHERE json_extract(value, '$.source') = 'person'); |
| 17 | |