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

feat(misc): add more logging while running migrations #27063

Merged
merged 1 commit into from
Jul 31, 2024
Merged

feat(misc): add more logging while running migrations #27063

merged 1 commit into from
Jul 31, 2024

Conversation

DanielRose
Copy link
Contributor

Current Behavior

When running migrations, the user currently only sees any logging feedback when a migration has done any changes.

This causes the following problems:

  1. Especially for large codebases and/or long-running migrations, this can result in nothing being shown for a long time. In my case, running the migrations for Nx 18 => 19 (which also upgrades Angular 17 => 18) this takes several hours, with almost no feedback on what has been done so far.
  2. Before the migrations are run, they are sorted. However, the sorted list is not displayed to the user. The user may be confused as to why a migration is run "out-of-order". Also, if the migrations are aborted (either manually or due to a crash), it is difficult for the user to know which migrations have been run already, and thus could be skipped.

Expected Behavior

This adds some more logging:

  1. Before the migrations are run, displays the sorted list of migrations
  2. Before each migration is run, displays the migration which will be run
  3. After each migration is run, always displays a completion message. If no changes were made, also displays that as message.

Note that I marked this as "feature", but I'm not sure if it is a new feature, or a "chore" or a "fix"

@DanielRose DanielRose requested a review from a team as a code owner July 23, 2024 11:16
@DanielRose DanielRose requested a review from Cammisuli July 23, 2024 11:16
Copy link

vercel bot commented Jul 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Jul 30, 2024 8:08am

@DanielRose DanielRose requested review from meeroslav, mandarini and a team as code owners July 29, 2024 09:13
@DanielRose
Copy link
Contributor Author

The e2e tests in multiple-release-branches.test.ts failed sometimes. I investigated the issue, and traced it to the random suffix being created by the uniq helper function. Since it used Math.random directly, the suffix could be shorter or longer, which apparently messes up the internal ordering of the packages.

As fix, I used a helper function based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random#getting_a_random_integer_between_two_values to ensure that the random value always has 7 digits.

@JamesHenry
Copy link
Collaborator

@DanielRose Thanks so much for figuring out that cause, it's been on my list for a while but it's been rare enough that it's never jumped to the highest priority. I think we can further simplify the implementation details by just using padStart so I've gone ahead and applied that in its own commit so that I can be tracked more easily: #27186

Please could you revert yours and pull that in?

The user previously had no feedback on how far the migrations have
progressed, unless any changes were done. Especially if there are many
long-running migration steps, this was unsatisfactory.
@DanielRose
Copy link
Contributor Author

@DanielRose Thanks so much for figuring out that cause, it's been on my list for a while but it's been rare enough that it's never jumped to the highest priority. I think we can further simplify the implementation details by just using padStart so I've gone ahead and applied that in its own commit so that I can be tracked more easily: #27186

Please could you revert yours and pull that in?

Rebased on the latest state, excluding the test fixes.

@DanielRose DanielRose requested a review from JamesHenry July 31, 2024 12:18
@JamesHenry JamesHenry merged commit adbb861 into nrwl:master Jul 31, 2024
6 checks passed
@JamesHenry
Copy link
Collaborator

Thanks again, @DanielRose!

@DanielRose DanielRose deleted the features/add-migration-step-logging branch August 1, 2024 06:54
FrozenPandaz pushed a commit that referenced this pull request Aug 1, 2024
ZackDeRose pushed a commit to ZackDeRose/nx that referenced this pull request Aug 8, 2024
Copy link

github-actions bot commented Aug 9, 2024

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants