From 04f09d7b9e3bbab84e1f8d483f52c744890788d8 Mon Sep 17 00:00:00 2001 From: Shubham Agrawal Date: Fri, 19 Sep 2025 22:11:03 +0530 Subject: [PATCH 1/2] Updated RenameReceiptFilename migration to different property --- src/libs/migrations/RenameReceiptFilename.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/libs/migrations/RenameReceiptFilename.ts b/src/libs/migrations/RenameReceiptFilename.ts index 5f71dec3db0d..14ab9e8351f1 100644 --- a/src/libs/migrations/RenameReceiptFilename.ts +++ b/src/libs/migrations/RenameReceiptFilename.ts @@ -5,7 +5,6 @@ import ONYXKEYS from '@src/ONYXKEYS'; import type Transaction from '@src/types/onyx/Transaction'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; -type OldTransaction = Transaction & {receiptFilename?: string}; type TransactionKey = `${typeof ONYXKEYS.COLLECTION.TRANSACTION}${string}`; // This migration changes the property name on a transaction from receiptFilename to filename so that it matches what is stored in the database @@ -13,10 +12,10 @@ export default function () { return new Promise((resolve) => { // Connect to the TRANSACTION collection key in Onyx to get all of the stored transactions. // Go through each transaction and change the property name - const connection = Onyx.connect({ + const connection = Onyx.connectWithoutView({ key: ONYXKEYS.COLLECTION.TRANSACTION, waitForCollectionCallback: true, - callback: (transactions: OnyxCollection) => { + callback: (transactions: OnyxCollection) => { Onyx.disconnect(connection); if (!transactions || isEmptyObject(transactions)) { @@ -24,9 +23,9 @@ export default function () { return resolve(); } - const transactionsWithReceipt: Array> = Object.values(transactions).filter((transaction) => transaction?.receiptFilename); + const transactionsWithReceipt: Array> = Object.values(transactions).filter((transaction) => transaction?.filename); if (!transactionsWithReceipt?.length) { - Log.info('[Migrate Onyx] Skipped migration RenameReceiptFilename because there were no transactions with the receiptFilename property'); + Log.info('[Migrate Onyx] Skipped migration RenameReceiptFilename because there were no transactions with the filename property'); return resolve(); } Log.info('[Migrate Onyx] Running RenameReceiptFilename migration'); @@ -35,14 +34,16 @@ export default function () { if (!transaction) { return acc; } - Log.info(`[Migrate Onyx] Renaming receiptFilename ${transaction.receiptFilename} to filename`); + Log.info(`[Migrate Onyx] Renaming filename ${transaction.filename} to receipt.filename`); acc[`${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`] = { - filename: transaction.receiptFilename, - receiptFilename: null, + receipt: { + filename: transaction.filename, + }, + filename: null, }; return acc; }, - {} as Record>, + {} as Record>, ); // eslint-disable-next-line rulesdir/prefer-actions-set-data From 5fb34132fee1ea75c6472f1642fd622f39e40018 Mon Sep 17 00:00:00 2001 From: Shubham Agrawal <58412969+shubham1206agra@users.noreply.github.com> Date: Wed, 1 Oct 2025 21:04:14 +0530 Subject: [PATCH 2/2] Apply suggestions from code review --- src/libs/migrations/RenameReceiptFilename.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/migrations/RenameReceiptFilename.ts b/src/libs/migrations/RenameReceiptFilename.ts index 14ab9e8351f1..c7730411d0ef 100644 --- a/src/libs/migrations/RenameReceiptFilename.ts +++ b/src/libs/migrations/RenameReceiptFilename.ts @@ -7,7 +7,7 @@ import {isEmptyObject} from '@src/types/utils/EmptyObject'; type TransactionKey = `${typeof ONYXKEYS.COLLECTION.TRANSACTION}${string}`; -// This migration changes the property name on a transaction from receiptFilename to filename so that it matches what is stored in the database +// This migration moves filename from the transaction root to transaction.receipt.filename to match the database structure. export default function () { return new Promise((resolve) => { // Connect to the TRANSACTION collection key in Onyx to get all of the stored transactions.