Skip to content

feat(pi): prefix Pi Durable's tables in actor sqlite - #345

Merged
eersnington merged 1 commit into
chore/pi-durable-1.1from
feat/pi-table-prefix
Oct 8, 2026
Merged

eersnington merged 1 commit into
chore/pi-durable-1.1from
feat/pi-table-prefix

Conversation

@eersnington

@eersnington eersnington commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Pi Durable's tables (conversations, entries, tasks, submissions, documents, ...) had no prefix and shared the Actor's SQLite with the app's own tables. An app could not create a tasks or documents table of its own.

conversations        →  pi_conversations
entries              →  pi_entries
tasks                →  pi_tasks
submissions          →  pi_submissions
documents            →  pi_documents
document_revisions   →  pi_document_revisions
record_ids           →  pi_record_ids
durable_metadata     →  pi_durable_metadata
durable_schema       →  pi_durable_schema

New SQL (actor-sqlite.ts). All of Pi's SQL passes through actorSqliteExecutor, which now rewrites Pi's table names:

export const PI_DURABLE_TABLES = [
	"durable_schema",
	...tables named by CREATE TABLE in Pi's SQLITE_MIGRATIONS,
];
// exec, run, get, and all send prefixTables(sql): \bconversations\b → pi_conversations
  • The names come from Pi's exported SQLITE_MIGRATIONS, so a table that a later Pi version adds gets the prefix too.
  • In Pi 1.0.4 and 1.1.0, these names appear in Pi's SQL only as table names.

Stored agents (storage.ts). Migration 4 renames the tables of agents from 0.5.1 and earlier, inside RivetKit's migration savepoint:

for (const table of PI_DURABLE_TABLES)
	if (table exists) ALTER TABLE ${table} RENAME TO pi_${table}

Rollback. RivetKit's migrations() refuses a stored version newer than the code:

0.5.1 agent ──wakes on 0.5.2──▶ migrations 3 and 4 run; conversations and files are kept
0.5.2 agent ──wakes on 0.5.1──▶ does not start: "migration version 4 ... is newer than supported version 2"
                                 the data is kept; it starts again on 0.5.2

So 0.5.1 never opens the renamed tables and creates new, empty Pi tables. The client sees guard.actor_wake_retries_exceeded; the server log names the migration.


This is part 8 of 9 in a stack:

@eersnington
eersnington force-pushed the feat/pi-table-prefix branch from 969792f to 848633c Compare October 8, 2026 15:40
@eersnington eersnington changed the title feat(pi): prefix Pi Durable's tables with pi_ feat(pi): prefix Pi Durable's tables in actor sqlite Oct 8, 2026
@eersnington
eersnington added this pull request to stack #347 October 8, 2026 16:05
@eersnington
eersnington merged commit 3896b46 into main Oct 8, 2026
0 of 6 checks passed
@eersnington
eersnington deleted the feat/pi-table-prefix branch October 8, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant