diff --git a/src/infra/state-migrations.media-persistence.historical-schema.test-support.ts b/src/infra/state-migrations.media-persistence.historical-schema.test-support.ts index fead7aa3c4ad..f4595ed60180 100644 --- a/src/infra/state-migrations.media-persistence.historical-schema.test-support.ts +++ b/src/infra/state-migrations.media-persistence.historical-schema.test-support.ts @@ -42,6 +42,7 @@ function removeSchemaRange(sql: string, startMarker: string, endMarker: string): export function historicalV15AgentSchemaSql(): string { let sql = restoreHistoricalAgentLeaseSchema(OPENCLAW_AGENT_SCHEMA_SQL) .replace(" entry_valid INTEGER NOT NULL DEFAULT 0 CHECK (entry_valid IN (-1, 0, 1)),\n", "") + .replace(" project_id TEXT,\n", "") .replace( " owner_actor_type TEXT,\n owner_actor_id TEXT,\n owner_assigned_by_type TEXT,\n owner_assigned_by_id TEXT,\n owner_assigned_at INTEGER,\n", "", diff --git a/src/infra/state-migrations.media-persistence.historical-v14.test.ts b/src/infra/state-migrations.media-persistence.historical-v14.test.ts index 179507e53974..9c1aae110725 100644 --- a/src/infra/state-migrations.media-persistence.historical-v14.test.ts +++ b/src/infra/state-migrations.media-persistence.historical-v14.test.ts @@ -26,8 +26,9 @@ describe("legacy media persistence Doctor migration from historical v14", () => it("migrates a copy of the exact v2026.7.2-beta.4 schema without losing its session", () => { const historicalSchema = historicalV14AgentSchemaSql(); expect(createHash("sha256").update(historicalSchema).digest("hex")).toBe( - "dfb2a98c9418eb1032e82e4310c7bde41700e4a0af05a2464673e9c4ece11fd1", + "955889668707fbccab70b80b5058af5a1587fd35ae32a80f8605179a68fb5117", ); + expect(historicalSchema).not.toContain(" project_id TEXT,\n"); const stateDir = makeTempDir(tempDirs, "media-persistence-historical-v14-"); const env = { OPENCLAW_STATE_DIR: stateDir }; diff --git a/src/infra/state-migrations.media-persistence.historical-v15.test.ts b/src/infra/state-migrations.media-persistence.historical-v15.test.ts index 8bc4cdcd7331..bad90b2b548e 100644 --- a/src/infra/state-migrations.media-persistence.historical-v15.test.ts +++ b/src/infra/state-migrations.media-persistence.historical-v15.test.ts @@ -26,7 +26,7 @@ describe("legacy media persistence Doctor migration from historical v15", () => it("converges the exact 509a5f0373764 schema before current-index repair", () => { const historicalSchema = historicalV15AgentSchemaSql(); expect(createHash("sha256").update(historicalSchema).digest("hex")).toBe( - "2ad94b064159086923e24acf4e11cb77546fca71646e7f49c7a6d40d2a22890a", + "75953ef97a738251822fc5aaf283bbe55fbcabe8702ad771892cdafc85d8e6b9", ); const stateDir = makeTempDir(tempDirs, "media-persistence-historical-v15-"); diff --git a/src/state/openclaw-agent-db-schema-helpers.ts b/src/state/openclaw-agent-db-schema-helpers.ts index 35f2d4d7684b..8f3bc49dfe6a 100644 --- a/src/state/openclaw-agent-db-schema-helpers.ts +++ b/src/state/openclaw-agent-db-schema-helpers.ts @@ -26,7 +26,10 @@ import { CONTEXT_ENGINE_TURN_OUTBOX_TABLE } from "./openclaw-agent-context-engin import { FIRST_USE_ADDITIVE_AGENT_COLUMN_DEFINITIONS } from "./openclaw-agent-db-additive-columns.js"; import { OPENCLAW_AGENT_SCHEMA_VERSION } from "./openclaw-agent-db-contract.js"; import { OpenClawAgentDatabaseMediaMigrationRequiredError } from "./openclaw-agent-db-migration-required.js"; -import { ensureSessionEntryValidityProjection } from "./openclaw-agent-db-session-migrations.js"; +import { + ensureSessionEntryValidityProjection, + ensureSessionProjectColumn, +} from "./openclaw-agent-db-session-migrations.js"; import { MESSAGE_TOOL_RUN_OUTCOMES_TABLE } from "./openclaw-agent-message-tool-outcome-schema.js"; import { ensureOpenClawAgentProgressCardSchemaInTransaction, @@ -186,6 +189,7 @@ export function repairAndAssertOpenClawAgentV14SchemaForMigration( ); } + ensureSessionProjectColumn(database); ensureSessionEntryValidityProjection(database); ensureSessionKeyContractSchemaInTransaction(database);