Skip to content

Commit a965a06

Browse files
committed
core: add OPENCODE_SKIP_MIGRATIONS flag to bypass database migrations
Allows users to skip automatic database migrations by setting the OPENCODE_SKIP_MIGRATIONS environment variable. Useful for testing scenarios or when manually managing database state.
1 parent 0654f28 commit a965a06

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

packages/opencode/src/flag/flag.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export namespace Flag {
6161
export const OPENCODE_MODELS_URL = process.env["OPENCODE_MODELS_URL"]
6262
export const OPENCODE_MODELS_PATH = process.env["OPENCODE_MODELS_PATH"]
6363
export const OPENCODE_DISABLE_CHANNEL_DB = truthy("OPENCODE_DISABLE_CHANNEL_DB")
64+
export const OPENCODE_SKIP_MIGRATIONS = truthy("OPENCODE_SKIP_MIGRATIONS")
6465

6566
function number(key: string) {
6667
const value = process.env[key]

packages/opencode/src/storage/db.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ export namespace Database {
106106
count: entries.length,
107107
mode: typeof OPENCODE_MIGRATIONS !== "undefined" ? "bundled" : "dev",
108108
})
109+
if (Flag.OPENCODE_SKIP_MIGRATIONS) {
110+
for (const item of entries) {
111+
item.sql = "select 1;"
112+
}
113+
}
109114
migrate(db, entries)
110115
}
111116

0 commit comments

Comments
 (0)