diff --git a/ts/sql/migrations/index.ts b/ts/sql/migrations/index.ts index 6ac32e9ca19..5519aabe6eb 100644 --- a/ts/sql/migrations/index.ts +++ b/ts/sql/migrations/index.ts @@ -1993,4 +1993,8 @@ export function updateSchema(db: Database, logger: LoggerType): void { runSchemaUpdate(userVersion, db, logger); } + + if (userVersion !== maxUserVersion) { + db.pragma('optimize'); + } }