fix revert on unpublished app

This commit is contained in:
Martin McKeaveney 2021-11-08 13:06:25 +01:00
parent 6489d61fd1
commit 7c21645799
1 changed files with 7 additions and 0 deletions

View File

@ -82,6 +82,13 @@ exports.revert = async ctx => {
const db = new CouchDB(productionAppId, { skip_setup: true })
const info = await db.info()
if (info.error) throw info.error
const deploymentDoc = await db.get(DocumentTypes.DEPLOYMENTS)
if (
!deploymentDoc.history ||
Object.keys(deploymentDoc.history).length === 0
) {
throw new Error("No deployments for app")
}
} catch (err) {
return ctx.throw(400, "App has not yet been deployed")
}