diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d4c9e8f..02ba6e8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## 0.1.44-beta.15 - 2026-09-14 + +### Fixed + +- Restore compatibility with databases created by beta.11 and later by bundling + the previously released TODO target-lock migration with its original identity. + +### Tests + +- Verify the beta.11 migration hash and confirm compatible databases are inspected + without changing their bytes. + ## 0.1.44-beta.14 - 2026-09-14 ### Added diff --git a/src/mendcode/packages/opencode/migration/20260912160000_todo_target_lock/migration.sql b/src/mendcode/packages/opencode/migration/20260912160000_todo_target_lock/migration.sql new file mode 100644 index 00000000..a3b577d4 --- /dev/null +++ b/src/mendcode/packages/opencode/migration/20260912160000_todo_target_lock/migration.sql @@ -0,0 +1,8 @@ +CREATE TABLE `todo_target_lock` ( + `session_id` text PRIMARY KEY NOT NULL, + `revision` integer NOT NULL, + `data` text NOT NULL, + `time_created` integer NOT NULL, + `time_updated` integer NOT NULL, + FOREIGN KEY (`session_id`) REFERENCES `session`(`id`) ON UPDATE no action ON DELETE cascade +); diff --git a/src/mendcode/packages/opencode/test/storage/compatibility.test.ts b/src/mendcode/packages/opencode/test/storage/compatibility.test.ts index 657d75ab..b6bc7efb 100644 --- a/src/mendcode/packages/opencode/test/storage/compatibility.test.ts +++ b/src/mendcode/packages/opencode/test/storage/compatibility.test.ts @@ -10,7 +10,7 @@ import { inspectCompatibility, recordSchemaIdentity, } from "../../src/storage/compatibility" -import { identifyMigrations } from "../../src/storage/migration-journal" +import { identifyMigrations, supportedMigrationJournal } from "../../src/storage/migration-journal" import { init } from "../../src/storage/db.bun" import { mendChannelDbPath } from "../../src/storage/resolve-default-sqlite-path" @@ -50,6 +50,27 @@ test("known legacy schema is compatible; persisted SQL identity rejects drift", expect(inspectCompatibility(file, [{ ...journal[0], hash: "f".repeat(64) }]).compatible).toBe(false) }) +test("target-lock migration from beta 11 remains compatible without changing database bytes", () => { + const target = supportedMigrationJournal().find((entry) => entry.name === "20260912160000_todo_target_lock") + expect(target).toEqual({ + name: "20260912160000_todo_target_lock", + timestamp: 1789228800000, + hash: "70cfa4c0564c863794823218a7e39e645c10b6a99ffa47b39d4eb87bd41e6ef1", + }) + const file = path.join(root, "target-lock.db") + const db = new Database(file, { create: true }) + db.run("CREATE TABLE __drizzle_migrations (name TEXT, created_at NUMERIC)") + db.run("CREATE TABLE __mendcode_schema_identity (name TEXT PRIMARY KEY, timestamp INTEGER NOT NULL, hash TEXT NOT NULL)") + db.run("INSERT INTO __drizzle_migrations VALUES (?, ?)", [target!.name, target!.timestamp]) + db.run("INSERT INTO __mendcode_schema_identity VALUES (?, ?, ?)", [target!.name, target!.timestamp, target!.hash]) + db.close() + const before = readFileSync(file) + const result = inspectCompatibility(file, supportedMigrationJournal()) + expect(result.compatible).toBe(true) + expect(result.legacy).toBe(false) + expect(readFileSync(file)).toEqual(before) +}) + test("snapshot includes WAL commits only when migrations are pending", () => { const { file, db } = fixture("backup") db.run("PRAGMA journal_mode=WAL")