Skip to content

Commit

Permalink
Migrate migrateOnyx module
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuuszzzzz committed Feb 13, 2024
1 parent 745648f commit 0590d43
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/libs/migrateOnyx.js → src/libs/migrateOnyx.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import _ from 'underscore';
import Log from './Log';
import KeyReportActionsDraftByReportActionID from './migrations/KeyReportActionsDraftByReportActionID';
import PersonalDetailsByAccountID from './migrations/PersonalDetailsByAccountID';
import RemoveEmptyReportActionsDrafts from './migrations/RemoveEmptyReportActionsDrafts';
import RenameReceiptFilename from './migrations/RenameReceiptFilename';
import TransactionBackupsToCollection from './migrations/TransactionBackupsToCollection';

export default function () {
export default function (): Promise<void> {
const startTime = Date.now();
Log.info('[Migrate Onyx] start');

return new Promise((resolve) => {
// Add all migrations to an array so they are executed in order
const migrationPromises = [PersonalDetailsByAccountID, RenameReceiptFilename, KeyReportActionsDraftByReportActionID, TransactionBackupsToCollection, RemoveEmptyReportActionsDrafts];
const migrationPromises = [RenameReceiptFilename, KeyReportActionsDraftByReportActionID, TransactionBackupsToCollection, RemoveEmptyReportActionsDrafts];

// 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.
/* eslint-disable arrow-body-style */
_.reduce(
migrationPromises,
migrationPromises.reduce(
(previousPromise, migrationPromise) => {
return previousPromise.then(() => {
return migrationPromise();
Expand Down

0 comments on commit 0590d43

Please sign in to comment.