Merge branch 'master' into cheeks-lab-day-fields

This commit is contained in:
Andrew Kingston 2024-11-15 11:32:08 +00:00 committed by GitHub
commit 7d0faf9e89
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{ {
"$schema": "node_modules/lerna/schemas/lerna-schema.json", "$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "3.2.0", "version": "3.2.1",
"npmClient": "yarn", "npmClient": "yarn",
"packages": [ "packages": [
"packages/*", "packages/*",

View File

@ -153,7 +153,11 @@ async function createInstance(appId: string, template: AppTemplate) {
await createAllSearchIndex() await createAllSearchIndex()
if (template && template.useTemplate) { 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 { } else {
// create the users table // create the users table
await db.put(USERS_TABLE_SCHEMA) await db.put(USERS_TABLE_SCHEMA)

View File

@ -123,6 +123,7 @@ export async function updateWithExport(
// don't need obj store, the existing app already has everything we need // don't need obj store, the existing app already has everything we need
await backups.importApp(devId, tempDb, template, { await backups.importApp(devId, tempDb, template, {
importObjStoreContents: false, importObjStoreContents: false,
updateAttachmentColumns: true,
}) })
const newMetadata = await getNewAppMetadata(tempDb, appDb) const newMetadata = await getNewAppMetadata(tempDb, appDb)
// get the documents to copy // get the documents to copy

View File

@ -170,7 +170,10 @@ export async function importApp(
appId: string, appId: string,
db: Database, db: Database,
template: TemplateType, template: TemplateType,
opts: { importObjStoreContents: boolean } = { importObjStoreContents: true } opts: {
importObjStoreContents: boolean
updateAttachmentColumns: boolean
} = { importObjStoreContents: true, updateAttachmentColumns: true }
) { ) {
let prodAppId = dbCore.getProdAppID(appId) let prodAppId = dbCore.getProdAppID(appId)
let dbStream: any let dbStream: any
@ -219,7 +222,9 @@ export async function importApp(
if (!ok) { if (!ok) {
throw "Error loading database dump from template." throw "Error loading database dump from template."
} }
await updateAttachmentColumns(prodAppId, db) if (opts.updateAttachmentColumns) {
await updateAttachmentColumns(prodAppId, db)
}
await updateAutomations(prodAppId, db) await updateAutomations(prodAppId, db)
// clear up afterward // clear up afterward
if (tmpPath) { if (tmpPath) {