File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -151,6 +151,15 @@ export class FrameDatabase {
151151 );
152152 ` ) ;
153153
154+ // Migration: add retention_policy column if missing (pre-v0.8 databases)
155+ try {
156+ this . db . exec (
157+ "ALTER TABLE frames ADD COLUMN retention_policy TEXT DEFAULT 'default'"
158+ ) ;
159+ } catch {
160+ // Column already exists — safe to ignore
161+ }
162+
154163 // Create indexes for performance
155164 this . db . exec ( `
156165 CREATE INDEX IF NOT EXISTS idx_frames_run ON frames(run_id);
Original file line number Diff line number Diff line change @@ -151,25 +151,10 @@ export class SQLiteAdapter extends FeatureAwareDatabaseAdapter {
151151 ErrorCode . DB_CONNECTION_FAILED
152152 ) ;
153153
154- // Delegate base table creation to FrameDatabase (single canonical schema source)
154+ // Delegate base table creation + migrations to FrameDatabase (single canonical schema source)
155155 const frameDb = new FrameDatabase ( this . db ) ;
156156 frameDb . initSchema ( ) ;
157157
158- // Migration: add retention_policy column if not exists
159- try {
160- this . db . exec (
161- "ALTER TABLE frames ADD COLUMN retention_policy TEXT DEFAULT 'default'"
162- ) ;
163- logger . info ( 'Added retention_policy column to frames' ) ;
164- } catch {
165- // Column already exists — safe to ignore
166- }
167-
168- // Index for GC queries on retention_policy + age (must be after ALTER TABLE migration)
169- this . db . exec (
170- 'CREATE INDEX IF NOT EXISTS idx_frames_retention_created ON frames(retention_policy, created_at)'
171- ) ;
172-
173158 // Ensure cascade constraints exist on dependent tables for existing DBs
174159 try {
175160 this . ensureCascadeConstraints ( ) ;
You can’t perform that action at this time.
0 commit comments