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

Run migrations and refresh app state if relevant #7620

Merged
merged 28 commits into from
May 11, 2022
Merged

Conversation

TomatoToaster
Copy link
Contributor

@TomatoToaster TomatoToaster commented Feb 8, 2022

CC: @luacmartins (since you worked on this recently) @roryabraham @marcaaron

HOLD

  • Needs this PR to be on production, or else the new API command will error out.

Details

We will run FixAccount like we do in OldDot and reinitialize data if something changed for the user or we ran migrations. If FixAccount returns no changes (which it will 90% of the time), we will do nothing. This will work without refreshing the whole app state and users won't need to log out and log back in.

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/195477

Tests

Same as QA but done locally (with the other Web-E PR linked above active)

  • Verify that no errors appear in the JS console

QA Steps

You can reach out to amal@expensify.com @TomatoToaster to test this on staging if needed.

  1. Find an account that was made before 03/28/2022 (your expensifail should work)
  2. If you haven't logged into OldDot since the above date on this account that is ideal.
  3. Go to staging.new.expensify.com and open up the dev console and make sure you have verbose enabled:

image

  1. Filter the console commands by FixAccount

image

  1. Now log into your expensifail account. Verify that you see these commands fire off (If you don't see the third one, that's fine for this step, that means you likely logged into this account in OldDot some time after 03/28/2022):

image

  1. In another tab, log into the same account on OldDot, and then run this snippet in the console:
    NVP.set('expensify_migration_2022_03_28_policyExpenseChatMigration') Then refresh the page on NewDot and verify that the three commands in the above screenshot are there.

  2. Refresh the page one more time and verify you only see the first 2 commands:

image

  • Verify that no errors appear in the JS console

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

@TomatoToaster TomatoToaster self-assigned this Feb 8, 2022
@TomatoToaster
Copy link
Contributor Author

Hmm it does seem to be causing an infinite loop, still need to fix that.

@TomatoToaster TomatoToaster changed the title Refreshing Expenisfy app for migration Run migrations and refresh app state if relevant May 3, 2022
@TomatoToaster
Copy link
Contributor Author

It looks like this is mostly working now! Noting here that I need to use NVP.set('expensify_migration_2022_03_28_policyExpenseChatMigration') in OldDot's console to reset that NVP and test that the migrations rerun in AuthScreens for the corresponding account in NewDot. Important to note that this migration will only run for accounts made before 2022_03_28 so test accounts made after that won't ever run this migration.

@TomatoToaster TomatoToaster changed the title Run migrations and refresh app state if relevant [No QA] Run migrations and refresh app state if relevant May 5, 2022
@TomatoToaster TomatoToaster changed the title [No QA] Run migrations and refresh app state if relevant Run migrations and refresh app state if relevant May 5, 2022
@TomatoToaster TomatoToaster marked this pull request as ready for review May 5, 2022 18:34
@TomatoToaster TomatoToaster requested a review from a team as a code owner May 5, 2022 18:34
@melvin-bot melvin-bot bot removed the request for review from a team May 5, 2022 18:34
@TomatoToaster TomatoToaster added the InternalQA This pull request required internal QA label May 5, 2022
@TomatoToaster
Copy link
Contributor Author

The lint failure is related to this: #8882 (comment).

This PR can be reviewed before the hold is lifted and despite that lint fail (which isn't relevant to the files changed here).

Copy link
Contributor

@luacmartins luacmartins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple of comments. I'll test it now!

src/libs/API.js Outdated
Comment on lines 518 to 520
/**
* Runs command that will fix malformed data in a users account and also run migrations.
* It returns whether anything was changed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB not sure if this comment is necessary. All methods defined in API.js do the same thing for different commands/params.

src/libs/actions/App.js Show resolved Hide resolved
if (!response.changed) {
return;
}
Log.info('FixAccount found updates for this user, so data will be reinitalized', true, response);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Log.info('FixAccount found updates for this user, so data will be reinitalized', true, response);
Log.info('FixAccount found updates for this user, so data will be reinitialized', true, response);

@luacmartins
Copy link
Contributor

Tests steps are clear and it seemed to work!

Note: I noticed that this call always returned a change in my dev account. However, I did verify that the migration ran and the NVP was set.

Copy link
Contributor

@roryabraham roryabraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Late to the party, but LGTM 👍

@TomatoToaster
Copy link
Contributor Author

TomatoToaster commented May 10, 2022

HOLD will likely be released later today when the next deploy goes up. If there's no other comments, I'll merge it soon after that since we already have the approve and I don't think any other comments are likely to pop up.

@TomatoToaster TomatoToaster changed the title [HOLD] Run migrations and refresh app state if relevant Run migrations and refresh app state if relevant May 10, 2022
@TomatoToaster TomatoToaster merged commit ad3cbc9 into main May 11, 2022
@TomatoToaster TomatoToaster deleted the amal-migration-app branch May 11, 2022 01:36
@melvin-bot
Copy link

melvin-bot bot commented May 11, 2022

Triggered auto assignment to @bondydaa (InternalQA), see https://stackoverflow.com/c/expensify/questions/5042 for more details.

@melvin-bot
Copy link

melvin-bot bot commented May 11, 2022

@TomatoToaster looks like this was merged without passing tests. Please add a note explaining why this was done and remove the Emergency label if this is not an emergency.

@melvin-bot melvin-bot bot added the Emergency label May 11, 2022
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@bondydaa
Copy link
Contributor

unassigning myself since amal said he will QA

@bondydaa bondydaa removed their assignment May 11, 2022
@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @TomatoToaster in version: 1.1.58-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 failure ❌
🕸 web 🕸 success ✅

@roryabraham
Copy link
Contributor

We've got a bad bug on production right now, and since we can't CP to production (yet), our only way to fix it is by doing another full production deploy. So I'm going to take a crack at the internalQA for this bad boi

@roryabraham
Copy link
Contributor

Nice, this was a pass. Going to check it off the checklist

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @AndrewGable in version: 1.1.60-3 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 failure ❌
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
InternalQA This pull request required internal QA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants