فهرست منبع

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.
Dax Raad 6 ماه پیش
والد
کامیت
a965a06259
2فایلهای تغییر یافته به همراه6 افزوده شده و 0 حذف شده
  1. 1 0
      packages/opencode/src/flag/flag.ts
  2. 5 0
      packages/opencode/src/storage/db.ts

+ 1 - 0
packages/opencode/src/flag/flag.ts

@@ -61,6 +61,7 @@ export namespace Flag {
   export const OPENCODE_MODELS_URL = process.env["OPENCODE_MODELS_URL"]
   export const OPENCODE_MODELS_PATH = process.env["OPENCODE_MODELS_PATH"]
   export const OPENCODE_DISABLE_CHANNEL_DB = truthy("OPENCODE_DISABLE_CHANNEL_DB")
+  export const OPENCODE_SKIP_MIGRATIONS = truthy("OPENCODE_SKIP_MIGRATIONS")
 
   function number(key: string) {
     const value = process.env[key]

+ 5 - 0
packages/opencode/src/storage/db.ts

@@ -106,6 +106,11 @@ export namespace Database {
         count: entries.length,
         mode: typeof OPENCODE_MIGRATIONS !== "undefined" ? "bundled" : "dev",
       })
+      if (Flag.OPENCODE_SKIP_MIGRATIONS) {
+        for (const item of entries) {
+          item.sql = "select 1;"
+        }
+      }
       migrate(db, entries)
     }