Files
2026-05-27 23:29:53 +01:00

35 lines
978 B
TypeScript

// Test helper — apply the saga table DDL that production gets from
// @suaveplan/api-host migration 2. Inlined here so the test suite
// doesn't have to pull api-host's full module graph.
import type { LedgerDb } from "../../src/persistence/persistence.types.js";
const INSTANCES_DDL = `
CREATE TABLE IF NOT EXISTS suaveplan_saga_instances (
id TEXT PRIMARY KEY,
plugin_name TEXT NOT NULL,
state TEXT NOT NULL,
payload_json TEXT NOT NULL,
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL
)
`;
const STEPS_DDL = `
CREATE TABLE IF NOT EXISTS suaveplan_saga_steps (
saga_id TEXT NOT NULL,
step_index INTEGER NOT NULL,
name TEXT NOT NULL,
state TEXT NOT NULL,
compensation_payload_json TEXT,
completed_at TEXT,
PRIMARY KEY (saga_id, step_index)
)
`;
/** Apply the saga DDL to a fresh in-memory ledger DB handle. */
export function applySagaSchema(db: LedgerDb): void {
db.run(INSTANCES_DDL);
db.run(STEPS_DDL);
}