Destroying instance DBs for an app before it is deleted.

This commit is contained in:
mike12345567 2020-10-13 16:31:14 +01:00
parent 4ea99592d9
commit 407d7606e9
1 changed files with 6 additions and 0 deletions

View File

@ -116,6 +116,12 @@ exports.delete = async function(ctx) {
const db = new CouchDB(ClientDb.name(getClientId(ctx))) const db = new CouchDB(ClientDb.name(getClientId(ctx)))
const app = await db.get(ctx.params.applicationId) const app = await db.get(ctx.params.applicationId)
const result = await db.remove(app) 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), { await fs.rmdir(join(budibaseAppsDir(), ctx.params.applicationId), {
recursive: true, recursive: true,
}) })