Merge pull request #3289 from Budibase/fix/prevent-revert
fix revert on unpublished app
This commit is contained in:
commit
08ea3ca3bc
|
@ -329,6 +329,19 @@ exports.sync = async ctx => {
|
||||||
ctx.throw(400, "This action cannot be performed for production apps")
|
ctx.throw(400, "This action cannot be performed for production apps")
|
||||||
}
|
}
|
||||||
const prodAppId = getDeployedAppID(appId)
|
const prodAppId = getDeployedAppID(appId)
|
||||||
|
|
||||||
|
try {
|
||||||
|
const prodDb = new CouchDB(prodAppId, { skip_setup: true })
|
||||||
|
const info = await prodDb.info()
|
||||||
|
if (info.error) throw info.error
|
||||||
|
} catch (err) {
|
||||||
|
// the database doesn't exist. Don't replicate
|
||||||
|
ctx.body = {
|
||||||
|
message: "App sync not required, app not deployed.",
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const replication = new Replication({
|
const replication = new Replication({
|
||||||
source: prodAppId,
|
source: prodAppId,
|
||||||
target: appId,
|
target: appId,
|
||||||
|
|
|
@ -82,6 +82,13 @@ exports.revert = async ctx => {
|
||||||
const db = new CouchDB(productionAppId, { skip_setup: true })
|
const db = new CouchDB(productionAppId, { skip_setup: true })
|
||||||
const info = await db.info()
|
const info = await db.info()
|
||||||
if (info.error) throw info.error
|
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) {
|
} catch (err) {
|
||||||
return ctx.throw(400, "App has not yet been deployed")
|
return ctx.throw(400, "App has not yet been deployed")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue