Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent attachment column updates when importing budibase templates #15000

Merged
merged 2 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/server/src/api/controllers/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,11 @@ async function createInstance(appId: string, template: AppTemplate) {
await createAllSearchIndex()

if (template && template.useTemplate) {
await sdk.backups.importApp(appId, db, template)
const opts = {
importObjStoreContents: true,
updateAttachmentColumns: !template.key, // preserve attachments when using Budibase templates
}
await sdk.backups.importApp(appId, db, template, opts)
} else {
// create the users table
await db.put(USERS_TABLE_SCHEMA)
Expand Down
1 change: 1 addition & 0 deletions packages/server/src/sdk/app/applications/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export async function updateWithExport(
// don't need obj store, the existing app already has everything we need
await backups.importApp(devId, tempDb, template, {
importObjStoreContents: false,
updateAttachmentColumns: true,
})
const newMetadata = await getNewAppMetadata(tempDb, appDb)
// get the documents to copy
Expand Down
9 changes: 7 additions & 2 deletions packages/server/src/sdk/app/backups/imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ export async function importApp(
appId: string,
db: Database,
template: TemplateType,
opts: { importObjStoreContents: boolean } = { importObjStoreContents: true }
opts: {
importObjStoreContents: boolean
updateAttachmentColumns: boolean
} = { importObjStoreContents: true, updateAttachmentColumns: true }
aptkingston marked this conversation as resolved.
Show resolved Hide resolved
) {
let prodAppId = dbCore.getProdAppID(appId)
let dbStream: any
Expand Down Expand Up @@ -219,7 +222,9 @@ export async function importApp(
if (!ok) {
throw "Error loading database dump from template."
}
await updateAttachmentColumns(prodAppId, db)
if (opts.updateAttachmentColumns) {
await updateAttachmentColumns(prodAppId, db)
}
await updateAutomations(prodAppId, db)
// clear up afterward
if (tmpPath) {
Expand Down
Loading