File tree Expand file tree Collapse file tree
packages/opencode/src/storage Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -93,6 +93,14 @@ export const Client = lazy(() => {
9393 db . run ( "PRAGMA foreign_keys = ON" )
9494 db . run ( "PRAGMA wal_checkpoint(PASSIVE)" )
9595
96+ // One-time auto-vacuum migration: switch from none (0) to incremental (2)
97+ const autoVacuum = db . $client . prepare ( "PRAGMA auto_vacuum" ) . get ( ) as { auto_vacuum : number } | undefined
98+ if ( autoVacuum ?. auto_vacuum === 0 ) {
99+ log . info ( "enabling incremental auto_vacuum" )
100+ db . run ( "PRAGMA auto_vacuum = 2" )
101+ db . run ( "VACUUM" )
102+ }
103+
96104 // Apply schema migrations
97105 const entries =
98106 typeof OPENCODE_MIGRATIONS !== "undefined"
@@ -170,3 +178,11 @@ export function transaction<T>(
170178 throw err
171179 }
172180}
181+
182+ export function checkpoint ( ) {
183+ Client ( ) . $client . run ( "PRAGMA wal_checkpoint(TRUNCATE)" )
184+ }
185+
186+ export function vacuum ( ) {
187+ Client ( ) . $client . run ( "PRAGMA incremental_vacuum" )
188+ }
You can’t perform that action at this time.
0 commit comments