diff --git a/packages/backend-core/src/migrations/migrations.ts b/packages/backend-core/src/migrations/migrations.ts index 2e3524775f..48d3b14a4a 100644 --- a/packages/backend-core/src/migrations/migrations.ts +++ b/packages/backend-core/src/migrations/migrations.ts @@ -86,7 +86,11 @@ export const runMigration = async ( count++ const lengthStatement = length > 1 ? `[${count}/${length}]` : "" - const db = getDB(dbName) + const db = getDB(dbName, { skip_setup: true }) + // DB doesn't exist - no-op required + if (!(await db.exists())) { + continue + } try { const doc = await getMigrationsDoc(db) diff --git a/packages/server/src/sdk/app/rows/attachments.ts b/packages/server/src/sdk/app/rows/attachments.ts index 67f58f8f2c..bd04f64146 100644 --- a/packages/server/src/sdk/app/rows/attachments.ts +++ b/packages/server/src/sdk/app/rows/attachments.ts @@ -13,13 +13,13 @@ function generateAttachmentFindParams( ) { const params: CouchFindOptions = { selector: { + $or: attachmentCols.map(col => ({ [col]: { $exists: true } })), _id: { $regex: `^${DocumentType.ROW}${SEPARATOR}${tableId}`, }, }, limit: FIND_LIMIT, } - attachmentCols.forEach(col => (params.selector[col] = { $exists: true })) if (bookmark) { params.bookmark = bookmark }