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(core): support collecting migrations excluding the already applied ones #14968

Conversation

leosvelperez
Copy link
Member

@leosvelperez leosvelperez commented Feb 13, 2023

Current Behavior

To run previously skipped migrations, the user needs to run nx migrate latest --from=nx@<older version>. This will collect all migrations from every package collected from the specified older version, regardless of whether the migration ran before. While it shouldn't pose an actual issue (migrations should be idempotent), it does take longer to run things that are not needed and it's harder for the user to know which migrations really matter.

Expected Behavior

To collect migrations while excluding migrations that were meant to be applied on previous updates, the user would use a new flag: nx migrate latest --from=nx@<older version> --exclude-applied-migrations. Note that migrations manually removed from the migrations.json on previous updates won't be collected.

Related Issue(s)

Fixes #

@vercel
Copy link

vercel bot commented Feb 13, 2023

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

Name Status Preview Comments Updated
nx-dev ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 21, 2023 at 3:53PM (UTC)

@leosvelperez leosvelperez self-assigned this Feb 13, 2023
@nx-cloud
Copy link

nx-cloud bot commented Feb 13, 2023

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 9058d73. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

@leosvelperez leosvelperez force-pushed the core/migrate-from-only-skipped-migrations branch from 6c8f7d6 to 354ac9e Compare February 14, 2023 11:27
@leosvelperez leosvelperez changed the title feat(core): support collecting migrations and filter out the already applied ones feat(core): support collecting migrations skipping the already applied ones Feb 14, 2023
@leosvelperez leosvelperez marked this pull request as ready for review February 14, 2023 12:10
@AgentEnder
Copy link
Member

I accidentally caused you some conflicts... 😞 Sorry.

Otherwise, this only works for packageJsonUpdates right? There's no way to tell if migrations.json generator based updates have previously been applied.

@leosvelperez
Copy link
Member Author

I accidentally caused you some conflicts... 😞 Sorry.

No worries!

Otherwise, this only works for packageJsonUpdates right? There's no way to tell if migrations.json generator based updates have previously been applied.

We can tell whether migrations were meant to run based on the currently installed versions and the requirements and target versions of each migration. That's what we're doing here. We definitely don't account for manually removed migrations. If someone needs to run all, they can still run nx migrate latest --from=nx@<older version> without the new flag. This is an opt-in feature, it won't change the default behavior. We could probably call it out better in docs.

@leosvelperez leosvelperez force-pushed the core/migrate-from-only-skipped-migrations branch 2 times, most recently from 0722825 to 2f9a123 Compare February 16, 2023 09:11
@leosvelperez leosvelperez force-pushed the core/migrate-from-only-skipped-migrations branch from 2f9a123 to eb55a8b Compare February 16, 2023 09:58
@leosvelperez leosvelperez force-pushed the core/migrate-from-only-skipped-migrations branch from eb55a8b to b4a83f1 Compare February 16, 2023 10:06
@leosvelperez leosvelperez force-pushed the core/migrate-from-only-skipped-migrations branch from b4a83f1 to 09b8930 Compare February 17, 2023 18:09
@leosvelperez leosvelperez changed the title feat(core): support collecting migrations skipping the already applied ones feat(core): support collecting migrations excluding the already applied ones Feb 17, 2023
@leosvelperez leosvelperez force-pushed the core/migrate-from-only-skipped-migrations branch from 578b560 to 516b55f Compare February 20, 2023 17:45
packages/nx/src/command-line/migrate.ts Outdated Show resolved Hide resolved
docs/generated/cli/migrate.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@isaacplmann isaacplmann left a comment

Choose a reason for hiding this comment

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

This is a much cleaner experience. I like it

@leosvelperez leosvelperez merged commit cde7cf9 into nrwl:master Feb 21, 2023
@leosvelperez leosvelperez deleted the core/migrate-from-only-skipped-migrations branch February 21, 2023 17:54
@github-actions
Copy link

github-actions bot commented Mar 3, 2023

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 Mar 3, 2023
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.

None yet

4 participants