Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove personalDetails as part of personalDetails migration #21844

Merged
merged 6 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/components/ArchivedReportFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ const propTypes = {
/** The reason the report was closed */
reason: PropTypes.string.isRequired,

/** (For accountMerged reason only), the email of the previous owner of this report. */
oldLogin: PropTypes.string,
/** (For accountMerged reason only), the accountID of the previous owner of this report. */
oldAccountID: PropTypes.number,

/** (For accountMerged reason only), the email of the account the previous owner was merged into */
newLogin: PropTypes.string,
/** (For accountMerged reason only), the accountID of the account the previous owner was merged into */
puneetlath marked this conversation as resolved.
Show resolved Hide resolved
newAccountID: PropTypes.number,
}).isRequired,
}),

Expand Down
7 changes: 7 additions & 0 deletions src/libs/migrations/PersonalDetailsByAccountID.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ export default function () {
}
});

// The personalDetails object has been replaced by personalDetailsList
// So if we find an instance of personalDetails we will clear it out
if (oldPersonalDetails) {
Log.info('[Migrate Onyx] PersonalDetailsByAccountID migration: removing personalDetails');
onyxData[DEPRECATED_ONYX_KEYS.PERSONAL_DETAILS] = null;
}

return Onyx.multiSet(onyxData);
},
);
Expand Down
25 changes: 25 additions & 0 deletions tests/unit/MigrationTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -845,5 +845,30 @@ describe('Migrations', () => {
},
});
}));

it('Should succeed in removing the personalDetails object if found in Onyx', () =>
Onyx.multiSet({
[`${DEPRECATED_ONYX_KEYS.PERSONAL_DETAILS}`]: {
'test1@account.com': {
accountID: 100,
login: 'test1@account.com',
},
'test2@account.com': {
accountID: 101,
login: 'test2@account.com',
},
},
})
.then(PersonalDetailsByAccountID)
.then(() => {
expect(LogSpy).toHaveBeenCalledWith('[Migrate Onyx] PersonalDetailsByAccountID migration: removing personalDetails');
const connectionID = Onyx.connect({
key: DEPRECATED_ONYX_KEYS.PERSONAL_DETAILS,
callback: (allPersonalDetails) => {
Onyx.disconnect(connectionID);
expect(allPersonalDetails).toBeNull();
},
});
}));
});
});