Removing migration change and fixing #9738 - making sure that exports with excludeRows enabled don't include attachments.

This commit is contained in:
mike12345567 2023-03-01 19:43:40 +00:00
parent 923e9d8ec4
commit 5b150e7748
3 changed files with 26 additions and 14 deletions

View File

@ -17,7 +17,6 @@ import {
MigrationNoOpOptions,
App,
} from "@budibase/types"
import env from "../environment"
export const getMigrationsDoc = async (db: any) => {
// get the migrations doc
@ -88,11 +87,7 @@ export const runMigration = async (
const lengthStatement = length > 1 ? `[${count}/${length}]` : ""
const db = getDB(dbName, { skip_setup: true })
// DB doesn't exist - no-op required
const dbExists = await db.exists()
if (!env.isTest() && !dbExists) {
continue
}
try {
const doc = await getMigrationsDoc(db)

View File

@ -1,2 +1,3 @@
export const DB_EXPORT_FILE = "db.txt"
export const GLOBAL_DB_EXPORT_FILE = "global.txt"
export const STATIC_APP_FILES = ["manifest.json", "budibase-client.js"]

View File

@ -7,10 +7,15 @@ import {
TABLE_ROW_PREFIX,
USER_METDATA_PREFIX,
} from "../../../db/utils"
import { DB_EXPORT_FILE, GLOBAL_DB_EXPORT_FILE } from "./constants"
import {
DB_EXPORT_FILE,
GLOBAL_DB_EXPORT_FILE,
STATIC_APP_FILES,
} from "./constants"
import fs from "fs"
import { join } from "path"
import env from "../../../environment"
const uuid = require("uuid/v4")
const tar = require("tar")
const MemoryStream = require("memorystream")
@ -91,14 +96,25 @@ export async function exportApp(appId: string, config?: ExportOpts) {
const prodAppId = dbCore.getProdAppID(appId)
const appPath = `${prodAppId}/`
// export bucket contents
let tmpPath
let tmpPath = createTempFolder(uuid())
if (!env.isTest()) {
tmpPath = await objectStore.retrieveDirectory(
ObjectStoreBuckets.APPS,
appPath
)
} else {
tmpPath = createTempFolder(uuid())
// write just the static files
if (config?.excludeRows) {
for (let path of STATIC_APP_FILES) {
const contents = await objectStore.retrieve(
ObjectStoreBuckets.APPS,
join(appPath, path)
)
fs.writeFileSync(join(tmpPath, path), contents)
}
}
// get all of the files
else {
tmpPath = await objectStore.retrieveDirectory(
ObjectStoreBuckets.APPS,
appPath
)
}
}
const downloadedPath = join(tmpPath, appPath)
if (fs.existsSync(downloadedPath)) {