cloudaxe-opencode/packages/opencode/migration
Kit Langton 6b7d434c3c fix(migration): unblock workspace.time_used add on populated tables
The 20260507164347_add_workspace_time migration shipped as

    ALTER TABLE \`workspace\` ADD \`time_used\` integer NOT NULL;

bun:sqlite (and standard SQLite) refuse to add a NOT NULL column
without a DEFAULT to a non-empty table. Anyone upgrading from
v1.14.41 (Hono) to v1.14.42 with populated workspace rows hit
"Cannot add a NOT NULL column with default value NULL" at startup
and the app crashed before reaching the TUI.

Dev users hadn't noticed because they pulled the migration when
their workspace table was empty (or under a fresh fixture); the
ALTER then succeeded and was journaled. State C (empty table at
migration time = success), state A/B (populated table at migration
time = crash) — only state A/B users hit the bug, and only on
upgrade from v1.14.41.

Replace with a table-recreate pattern that is idempotent across
both states. The SELECT pulls only columns from the v1.14.41
schema, so it works whether time_used exists or not. The new
table defines time_used with DEFAULT 0; existing rows reset to 0,
which is acceptable because time_used is a usage counter the app
re-derives anyway and is brand new in v1.14.42.

Verified locally on bun:sqlite for both states.
2026-05-09 14:02:18 -04:00
..
20260127222353_familiar_lady_ursula
20260211171708_add_project_commands
20260213144116_wakeful_the_professor
20260225215848_workspace
20260227213759_add_session_workspace_id
20260228203230_blue_harpoon core: make account login upgrades safe while adding multi-account workspace auth (#15487) 2026-03-10 12:53:47 -04:00
20260303231226_add_workspace_fields
20260309230000_move_org_to_state chore: generate 2026-03-10 16:56:30 +00:00
20260312043431_session_message_cursor chore: generate 2026-03-13 10:19:52 +00:00
20260323234822_events chore: generate 2026-03-25 14:48:44 +00:00
20260410174513_workspace-name chore: generate 2026-04-13 17:37:41 +00:00
20260413175956_chief_energizer chore: generate 2026-04-13 18:02:12 +00:00
20260423070820_add_icon_url_override chore: generate 2026-04-23 10:58:14 +00:00
20260427172553_slow_nightmare chore: generate 2026-05-03 02:10:52 +00:00
20260428004200_add_session_path chore: generate 2026-05-03 02:10:52 +00:00
20260501142318_next_venus chore: generate 2026-05-03 02:10:52 +00:00
20260504145000_add_sync_owner rebase migrations properly 2026-05-07 12:38:29 -04:00
20260507164347_add_workspace_time fix(migration): unblock workspace.time_used add on populated tables 2026-05-09 14:02:18 -04:00