Compare commits

...

1 Commits

Author SHA1 Message Date
Aiden Cline 2b47c034b3 fix(core): backfill project copy strategies 2026-06-13 15:50:44 -05:00
3 changed files with 38 additions and 0 deletions
+1
View File
@@ -37,5 +37,6 @@ export const migrations = (
import("./migration/20260611035744_credential"),
import("./migration/20260611192811_lush_chimera"),
import("./migration/20260612174303_project_dir_strategy"),
import("./migration/20260613210000_backfill_project_copy_strategy"),
])
).map((module) => module.default) satisfies DatabaseMigration.Migration[]
@@ -0,0 +1,13 @@
import { Effect } from "effect"
import type { DatabaseMigration } from "../migration"
export default {
id: "20260613210000_backfill_project_copy_strategy",
up(tx) {
return Effect.gen(function* () {
yield* tx.run(
`UPDATE \`project_directory\` SET \`strategy\` = 'git_worktree' WHERE \`type\` = 'git_worktree' AND \`strategy\` IS NULL;`,
)
})
},
} satisfies DatabaseMigration.Migration
@@ -14,6 +14,7 @@ import sessionMessageProjectionOrderMigration from "@opencode-ai/core/database/m
import eventSourcedSessionInputMigration from "@opencode-ai/core/database/migration/20260604172448_event_sourced_session_input"
import contextEpochAgentMigration from "@opencode-ai/core/database/migration/20260605042240_add_context_epoch_agent"
import simplifyIntegrationCredentialsMigration from "@opencode-ai/core/database/migration/20260611192811_lush_chimera"
import backfillProjectCopyStrategyMigration from "@opencode-ai/core/database/migration/20260613210000_backfill_project_copy_strategy"
import { ProjectV2 } from "@opencode-ai/core/project"
import { ProjectTable } from "@opencode-ai/core/project/sql"
import { AbsolutePath } from "@opencode-ai/core/schema"
@@ -150,6 +151,29 @@ describe("DatabaseMigration", () => {
)
})
test("backfills strategies for legacy project copies", async () => {
await run(
Effect.gen(function* () {
const db = yield* makeDb
yield* db.run(
sql`CREATE TABLE project_directory (project_id text NOT NULL, directory text NOT NULL, type text, strategy text, time_created integer NOT NULL, PRIMARY KEY (project_id, directory))`,
)
yield* db.run(
sql`INSERT INTO project_directory (project_id, directory, type, strategy, time_created) VALUES ('project', '/root', 'main', NULL, 1), ('project', '/copy', 'git_worktree', NULL, 2)`,
)
yield* DatabaseMigration.applyOnly(db, [backfillProjectCopyStrategyMigration])
expect(
yield* db.all(sql`SELECT directory, strategy FROM project_directory ORDER BY directory`),
).toEqual([
{ directory: "/copy", strategy: "git_worktree" },
{ directory: "/root", strategy: null },
])
}),
)
})
test("resets beta history and rebuilds event-sourced Session input storage", async () => {
await run(
Effect.gen(function* () {