Merge pull request #8670 from Budibase/fix/attachment-row-delete

Fix for attachment cleanup on internal table delete.
This commit is contained in:
deanhannigan 2022-11-14 15:01:22 +00:00 committed by GitHub
commit d357b0135a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -142,15 +142,15 @@ export async function destroy(ctx: any) {
const tableToDelete = await db.get(ctx.params.tableId) const tableToDelete = await db.get(ctx.params.tableId)
// Delete all rows for that table // Delete all rows for that table
const rows = await db.allDocs( const rowsData = await db.allDocs(
getRowParams(ctx.params.tableId, null, { getRowParams(ctx.params.tableId, null, {
include_docs: true, include_docs: true,
}) })
) )
await db.bulkDocs( await db.bulkDocs(
rows.rows.map((row: any) => ({ ...row.doc, _deleted: true })) rowsData.rows.map((row: any) => ({ ...row.doc, _deleted: true }))
) )
await quotas.removeRows(rows.rows.length, { await quotas.removeRows(rowsData.rows.length, {
tableId: ctx.params.tableId, tableId: ctx.params.tableId,
}) })
@ -179,7 +179,9 @@ export async function destroy(ctx: any) {
oldTable: null, oldTable: null,
deletion: true, deletion: true,
}) })
await cleanupAttachments(tableToDelete, { rows }) await cleanupAttachments(tableToDelete, {
rows: rowsData.rows.map((row: any) => row.doc),
})
return tableToDelete return tableToDelete
} }