diff --git a/src/libs/migrateOnyx.ts b/src/libs/migrateOnyx.ts index 64895456ef9c..bc22fc18a503 100644 --- a/src/libs/migrateOnyx.ts +++ b/src/libs/migrateOnyx.ts @@ -1,5 +1,4 @@ import Log from './Log'; -import RenameCardIsVirtual from './migrations/RenameCardIsVirtual'; import RenameReceiptFilename from './migrations/RenameReceiptFilename'; export default function () { @@ -8,7 +7,7 @@ export default function () { return new Promise((resolve) => { // Add all migrations to an array so they are executed in order - const migrationPromises = [RenameCardIsVirtual, RenameReceiptFilename]; + const migrationPromises = [RenameReceiptFilename]; // Reduce all promises down to a single promise. All promises run in a linear fashion, waiting for the // previous promise to finish before moving onto the next one. diff --git a/src/libs/migrations/RenameCardIsVirtual.ts b/src/libs/migrations/RenameCardIsVirtual.ts deleted file mode 100644 index 5238b05bb3b9..000000000000 --- a/src/libs/migrations/RenameCardIsVirtual.ts +++ /dev/null @@ -1,56 +0,0 @@ -import Onyx from 'react-native-onyx'; -import type {NullishDeep, OnyxEntry} from 'react-native-onyx'; -import Log from '@libs/Log'; -import ONYXKEYS from '@src/ONYXKEYS'; -import type {Card} from '@src/types/onyx'; -import {isEmptyObject} from '@src/types/utils/EmptyObject'; - -type OldCard = Card & {isVirtual?: boolean}; - -// This migration changes the property name on each card from card list from isVirtual to nameValuePairs.isVirtual -export default function () { - return new Promise((resolve) => { - // We still have the migration running so we use `connectWithoutView` here - const connection = Onyx.connectWithoutView({ - key: ONYXKEYS.CARD_LIST, - callback: (cardList: OnyxEntry>) => { - Onyx.disconnect(connection); - - if (!cardList || isEmptyObject(cardList)) { - Log.info('[Migrate Onyx] Skipped migration RenameCardIsVirtual because there are no cards linked to the account'); - return resolve(); - } - const cardsWithIsVirtualProp = Object.values(cardList).filter((card) => card?.nameValuePairs?.isVirtual !== undefined); - if (!cardsWithIsVirtualProp.length) { - Log.info('[Migrate Onyx] Skipped migration RenameCardIsVirtual because there were no cards with the isVirtual property'); - return resolve(); - } - - Log.info('[Migrate Onyx] Running RenameCardIsVirtual migration'); - const dataToSave = cardsWithIsVirtualProp.reduce( - (acc, card) => { - if (!card) { - return acc; - } - - acc[card.cardID] = { - nameValuePairs: { - isVirtual: card?.nameValuePairs?.isVirtual, - }, - isVirtual: undefined, - }; - - return acc; - }, - {} as Record>, - ); - - // eslint-disable-next-line rulesdir/prefer-actions-set-data - Onyx.merge(ONYXKEYS.CARD_LIST, dataToSave).then(() => { - Log.info(`[Migrate Onyx] Ran migration RenameCardIsVirtual and renamed ${Object.keys(dataToSave)?.length} properties`); - resolve(); - }); - }, - }); - }); -}