Dashboard › opencode › Distillation
f956d9e2-d699-4a59-aa32-7e212975d5de["lore_tm_v1_WnT4WB4JnfSENY-whkzJakaRJ8IqcYWsHesAEz9VT10","lore_tm_v1_H9Kast3gndsMfXiVT6a9wPMT2QDHkH3TimjB8xtI0rs","lore_tm_v1_f6Olk85cN6TM6uJ8LtywCnG5qAiQ4jEqHFHSbonq6Ok","lore_tm_v1_G70y4jOfYi0i3gYPsg1vDigsx_8FmMZHbx2AuubC2Ro","lore_tm_v1_okhBFymhrEZfjjS3G0QLNwlT6AIJCvJnqRN57uKUVqE","lore_tm_v1_9hBjO-rJK9bB76JLZNA6YMC4a1kvw6kU5ETHaWl9c_k","lore_tm_v1_HMnfnyrNjPunsv-7FML_56qtIXCOjzf1WQGLYtpkh00","lore_tm_v1_Ef2V3VehOfWs2wOzCBh1GD_CUsJyDHPcBR1Q5Yk6XUE","lore_tm_v1_oZNgo-cLG2Yg592bDdLlpdBMQzg6jZw_tQl2ej0dWeM","lore_tm_v1_1qBxskgY15IL66kfFfM2_VQGJtjuksP9Z3CyaMJ8dKg"]
Date: Sep 14, 2026
/home/byk/Code/opencode/packages/core/src/event/sql.ts defines EventSequenceTable as SQLite table event_sequence with aggregate_id text primary key, required integer seq, and nullable text owner_id./home/byk/Code/opencode/packages/core/src/event/sql.ts defines EventTable as SQLite table event: id is an EventV2.ID text primary key; required aggregate_id references EventSequenceTable.aggregate_id with onDelete: "cascade"; seq is a required integer; type is required text; and data is required JSON-mode text typed as Record<string, unknown>.event table has unique index event_aggregate_seq_idx on (aggregate_id, seq) and index event_aggregate_type_seq_idx on (aggregate_id, type, seq)./home/byk/Code/opencode/packages/core/script/migration.ts, /home/byk/Code/opencode/packages/core/test/database-migration.test.ts, /home/byk/Code/opencode/packages/core/src/database/migration.ts, /home/byk/Code/opencode/packages/core/src/database/migration.gen.ts, /home/byk/Code/opencode/packages/core/src/database/migration/20260511000411_data_migration_state.ts, and /home/byk/Code/opencode/packages/core/src/data-migration.sql.ts; several accompanying searches returned No files found./home/byk/Code/opencode/packages/core/src/database/migration.ts serializes DatabaseMigration.apply() calls with Semaphore.makeUnsafe(1). It queries non-SQLite tables; databases containing session run applyOnly(db, migrations), nonempty databases lacking session die with Database is not empty and has no session table, and empty databases transactionally run schema.up(tx), create migration(id TEXT PRIMARY KEY, time_completed INTEGER NOT NULL), and mark every known migration complete.DatabaseMigration.applyOnly(db, input) creates the migration journal if absent, loads completed IDs, skips completed migrations, and runs each outstanding migration.up(tx) plus its journal insert atomically in a transaction.applyOnly() seeds the new journal from __drizzle_migrations only when the new journal is empty. If the legacy table has a name column, it copies non-null names using INSERT OR IGNORE; otherwise it derives a %Y%m%d%H%M%S prefix from created_at, matches input migration IDs by prefix, and dies with Legacy migration timestamp ${entry.created_at} does not match any known migration when no migration matches./home/byk/Code/opencode/packages/core/src/database/schema.gen.ts directly creates event_sequence with aggregate_id, seq, and owner_id, then creates event with id, aggregate_id, seq, type, and data; event.aggregate_id has a cascading foreign key to event_sequence.aggregate_id./home/byk/Code/opencode/packages/core/src/database/schema.gen.ts creates tables in this order: 1. workspace, 2. data_migration, 3. account_state, 4. account, 5. control_account, 6. credential, 7. event_sequence, 8. event, 9. permission, 10. project_directory, 11. project, 12. message, 13. part, 14. session_context_epoch, 15. session_input, 16. session_message, 17. session, 18. todo (definition continued beyond the displayed lines).session_context_epoch(session_id, baseline, snapshot, baseline_seq); session_input(id, session_id, prompt, delivery, admitted_seq, promoted_seq, time_created); and session_message(id, session_id, type, seq, time_created, time_updated, data), each with cascading session foreign keys./home/byk/Code/opencode/packages/core/src/database/migration.gen.ts asynchronously imports and preserves 38 migrations in this exact order: 1. 20260127222353_familiar_lady_ursula, 2. 20260211171708_add_project_commands, 3. 20260213144116_wakeful_the_professor, 4. 20260225215848_workspace, 5. 20260227213759_add_session_workspace_id, 6. 20260228203230_blue_harpoon, 7. 20260303231226_add_workspace_fields, 8. 20260309230000_move_org_to_state, 9. 20260312043431_session_message_cursor, 10. 20260323234822_events, 11. 20260410174513_workspace-name, 12. 20260413175956_chief_energizer, 13. 20260423070820_add_icon_url_override, 14. 20260427172553_slow_nightmare, 15. 20260428004200_add_session_path, 16. 20260501142318_next_venus, 17. 20260504145000_add_sync_owner, 18. 20260507164347_add_workspace_time, 19. 20260510033149_session_usage, 20. 20260511000411_data_migration_state, 21. 20260511173437_session-metadata, 22. 20260601010001_normalize_storage_paths, 23. 20260601202201_amazing_prowler, 24. 20260602002951_lowly_union_jack, 25. 20260602182828_add_project_directories, 26. 20260603001617_session_message_projection_indexes, 27. 20260603040000_session_message_projection_order, 28. 20260603141458_session_input_inbox, 29. 20260603160727_jittery_ezekiel_stane, 30. 20260604172448_event_sourced_session_input, 31. 20260605003541_add_session_context_snapshot, 32. 20260605042240_add_context_epoch_agent, 33. 20260611035744_credential, 34. 20260611192811_lush_chimera, 35. 20260612174303_project_dir_strategy, 36. 20260622142730_simplify_session_context_epoch, 37. 20260622170816_reset_v2_session_state, 38. 20260622202450_simplify_session_input./home/byk/Code/opencode/packages/core/src/database/migration.gen.ts exist under /home/byk/Code/opencode/packages/core/src/database/migration/.