1
0
Fork 0
mirror of synced 2024-10-04 03:54:37 +13:00

Fix for #7865 - if you deleted a cron automation immediately after creating/publishing it there was a scenario where prod automations would be out of sync with dev automations and it wouldn't really delete. To get around this, we do an automation sync back to dev DB - meaning that the cron ID is known and can be disabled.

This commit is contained in:
mike12345567 2022-12-07 14:32:29 +00:00
parent eefba10623
commit 617863ddd1
2 changed files with 10 additions and 4 deletions

View file

@ -8,6 +8,7 @@ import {
} from "../../../automations/utils"
import { backups } from "@budibase/pro"
import { AppBackupTrigger } from "@budibase/types"
import sdk from "../../../sdk"
// the max time we can wait for an invalidation to complete before considering it failed
const MAX_PENDING_TIME_MS = 30 * 60000
@ -86,6 +87,9 @@ async function initDeployedApp(prodAppId: any) {
}
await Promise.all(promises)
console.log("Enabled cron triggers for deployed app..")
// sync the automations back to the dev DB - since there is now cron
// information attached
await sdk.applications.syncApp(dbCore.getDevAppID(prodAppId), { automationOnly: true })
}
async function deployApp(deployment: any, userId: string) {
@ -112,8 +116,6 @@ async function deployApp(deployment: any, userId: string) {
}
replication = new dbCore.Replication(config)
const devDb = context.getDevAppDB()
console.log("Compacting development DB")
await devDb.compact()
console.log("Replication object created")
await replication.replicate(replication.appReplicateOpts())
console.log("replication complete.. replacing app meta doc")

View file

@ -2,7 +2,7 @@ import env from "../../../environment"
import { db as dbCore, context } from "@budibase/backend-core"
import sdk from "../../"
export async function syncApp(appId: string) {
export async function syncApp(appId: string, opts?: { automationOnly?: boolean }) {
if (env.DISABLE_AUTO_PROD_APP_SYNC) {
return {
message:
@ -33,7 +33,11 @@ export async function syncApp(appId: string) {
})
let error
try {
await replication.replicate(replication.appReplicateOpts())
const replOpts = replication.appReplicateOpts()
if (opts?.automationOnly) {
replOpts.filter = (doc: any) => doc._id.startsWith(dbCore.DocumentType.AUTOMATION)
}
await replication.replicate()
} catch (err) {
error = err
} finally {