From 407d7606e9271bc07023d74871bc1418a60cae1e Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 13 Oct 2020 16:31:14 +0100 Subject: [PATCH] Destroying instance DBs for an app before it is deleted. --- packages/server/src/api/controllers/application.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/server/src/api/controllers/application.js b/packages/server/src/api/controllers/application.js index 53b8792f49..28e389b1d2 100644 --- a/packages/server/src/api/controllers/application.js +++ b/packages/server/src/api/controllers/application.js @@ -116,6 +116,12 @@ exports.delete = async function(ctx) { const db = new CouchDB(ClientDb.name(getClientId(ctx))) const app = await db.get(ctx.params.applicationId) const result = await db.remove(app) + for (let instance of app.instances) { + const instanceDb = new CouchDB(instance._id) + await instanceDb.destroy() + } + + // remove top level directory await fs.rmdir(join(budibaseAppsDir(), ctx.params.applicationId), { recursive: true, })