feat: deliver durable live signal intents

This commit is contained in:
2026-09-06 10:45:20 +00:00
parent ad564de23f
commit 26ac4c1cac
8 changed files with 227 additions and 13 deletions
+16 -1
View File
@@ -13,7 +13,10 @@ type migration struct {
sql string
}
var migrations = []migration{{version: 1, sql: schemaV1}}
var migrations = []migration{
{version: 1, sql: schemaV1},
{version: 2, sql: schemaV2},
}
func applyMigrations(ctx context.Context, db *sql.DB) error {
if _, err := db.ExecContext(ctx, `CREATE TABLE IF NOT EXISTS schema_migrations (
@@ -181,3 +184,15 @@ CREATE TABLE storage_counters (
) STRICT;
INSERT INTO storage_counters(singleton, command_charged_bytes, charge_version) VALUES (1, 0, 1);
`
const schemaV2 = `
CREATE TABLE signal_intents (
request_uuid BLOB PRIMARY KEY CHECK(length(request_uuid) = 16),
issue_uuid BLOB NOT NULL REFERENCES commands(issue_uuid) ON DELETE CASCADE CHECK(length(issue_uuid) = 16),
signal INTEGER NOT NULL CHECK(signal BETWEEN 1 AND 6),
command_revision INTEGER NOT NULL CHECK(command_revision > 0),
acknowledged INTEGER NOT NULL DEFAULT 0 CHECK(acknowledged IN (0,1)),
created_at INTEGER NOT NULL
) STRICT;
CREATE INDEX signal_intents_pending ON signal_intents(issue_uuid, command_revision, signal, acknowledged, created_at, request_uuid);
`