Skip to content

Commit

Permalink
fix(core): run migrations ordered by their target version (nrwl#21799)
Browse files Browse the repository at this point in the history
  • Loading branch information
leosvelperez authored Feb 13, 2024
1 parent b468904 commit 81f59ef
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/nx/src/command-line/migrate/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1367,8 +1367,19 @@ export async function executeMigrations(
const depsBeforeMigrations = getStringifiedPackageJsonDeps(root);

const migrationsWithNoChanges: typeof migrations = [];
const sortedMigrations = migrations.sort((a, b) => {
// special case for the split configuration migration to run first
if (a.name === '15-7-0-split-configuration-into-project-json-files') {
return -1;
}
if (b.name === '15-7-0-split-configuration-into-project-json-files') {
return 1;
}

return lt(a.version, b.version) ? -1 : 1;
});

for (const m of migrations) {
for (const m of sortedMigrations) {
try {
const { collection, collectionPath } = readMigrationCollection(
m.package,
Expand Down

0 comments on commit 81f59ef

Please sign in to comment.