diff --git a/core/app.js b/core/app.js index 76ddc8e02..20f76d003 100644 --- a/core/app.js +++ b/core/app.js @@ -416,6 +416,7 @@ class App { await this.pouch.addAllViews() await runMigrations(migrations, this) + await this.pouch.compact() if (wasUpdated && this.remote) { try { diff --git a/core/pouch/index.js b/core/pouch/index.js index a695b4678..6a0dc52c2 100644 --- a/core/pouch/index.js +++ b/core/pouch/index.js @@ -98,6 +98,16 @@ class Pouch { }) } + async compact() { + log.info('compacting db...') + + try { + await this.db.compact() + } catch (err) { + log.error('failed to compact db', { err, sentry: true }) + } + } + /* Mini ODM */ /* Catch uncaught exceptions raised by PouchDB when calling `allDocs`.