Skip to content

Commit

Permalink
Merge pull request #36416 from software-mansion-labs/ts/migrate-migra…
Browse files Browse the repository at this point in the history
…te-onyx

[TS Migration] Migrate 'migrateOnyx.js'
  • Loading branch information
stitesExpensify authored Feb 21, 2024
2 parents ea0c07b + e2e1467 commit b174f8a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 740 deletions.
15 changes: 5 additions & 10 deletions src/libs/migrateOnyx.js → src/libs/migrateOnyx.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
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,
(previousPromise, migrationPromise) => {
migrationPromises
.reduce((previousPromise, migrationPromise) => {
return previousPromise.then(() => {
return migrationPromise();
});
},
Promise.resolve(),
)
}, Promise.resolve())

// Once all migrations are done, resolve the main promise
.then(() => {
Expand Down
274 changes: 0 additions & 274 deletions src/libs/migrations/PersonalDetailsByAccountID.js

This file was deleted.

Loading

0 comments on commit b174f8a

Please sign in to comment.