Merge pull request #8970 from Budibase/fix/7865

Fix for removing cron automations immediately after publishing
This commit is contained in:
Michael Drury 2022-12-08 09:01:06 +00:00 committed by GitHub
commit 3188bf806f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import {
} from "../../../automations/utils" } from "../../../automations/utils"
import { backups } from "@budibase/pro" import { backups } from "@budibase/pro"
import { AppBackupTrigger } from "@budibase/types" import { AppBackupTrigger } from "@budibase/types"
import sdk from "../../../sdk"
// the max time we can wait for an invalidation to complete before considering it failed // the max time we can wait for an invalidation to complete before considering it failed
const MAX_PENDING_TIME_MS = 30 * 60000 const MAX_PENDING_TIME_MS = 30 * 60000
@ -86,6 +87,11 @@ async function initDeployedApp(prodAppId: any) {
} }
await Promise.all(promises) await Promise.all(promises)
console.log("Enabled cron triggers for deployed app..") 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) { async function deployApp(deployment: any, userId: string) {

View File

@ -2,7 +2,10 @@ import env from "../../../environment"
import { db as dbCore, context } from "@budibase/backend-core" import { db as dbCore, context } from "@budibase/backend-core"
import sdk from "../../" 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) { if (env.DISABLE_AUTO_PROD_APP_SYNC) {
return { return {
message: message:
@ -33,7 +36,12 @@ export async function syncApp(appId: string) {
}) })
let error let error
try { 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(replOpts)
} catch (err) { } catch (err) {
error = err error = err
} finally { } finally {