Storage migrations #
Storage upgrades run at daemon startup before sessions open. Core and extension
migrations have separate owners. The
extension runtime exposes migrate for
extension data migrations.
Startup order #
server.start calls
registry.prepare_storage before serving sessions.
Core migrations.run runs image storage,
transcript classification, session profiles, prompts, titles, usage-hour, and
waiting-input upgrades in that order. Each result is checked, so an error stops
the sequence. The last moves inputs from the retired pending_inputs table into
the inbox.
After the core upgrades, prepare_storage runs the kernel's
cell_images
upgrade and then the installed extensions' data migrations. cell_images moves
inline cell screenshots into the shared image store. It records its completion
as the cell_images row of the migrations table, so a home that already ran
it skips it. Keep that name if the migration moves again. The kernel's schema is
created by the runtime, not by an extension.
Paperclips extension contributes schema migrations alongside its table initializer. Extension-owned schema changes belong with their owner. See extensions and paperclips.
Compatibility and interruption #
session_prompts.run moves older session prompt columns into the prompt table. transcript_classes.run handles older transcript rows. Inspect each migration's transaction and marker logic before changing its restart behavior. These upgrades do not all share one transaction.
Foreign-key indexes #
Make each foreign key's child columns the leading columns of an index. For a
composite key, the index prefix must contain all child columns. An
INTEGER PRIMARY KEY needs no separate index.
Deletion looks up referencing child rows. Without an index, that lookup scans
the child table for each deleted parent row and can block the store writer.
test_every_foreign_key_column_is_indexed
checks this invariant across the schema. Preserve it when adding or changing
extension tables as well as core tables.
Migration test inventory #
test/e2e/migrations_test.py exercises startup with older data. Keep an upgrade scenario while its old format remains supported. A fresh database does not exercise that path. The normal test gate is described in test execution.