fix(medusa,cli): Resources not correctly loaded when running the migration scripts (#11108)

FIXES FRMW-2888

**What**
Since the migration scripts runner run as part of the migrate script, we were cleaning up the resources but we didn't take into consideration that links are loading automagically by just importing the links. The issue is that once a link have been imported, the next import will rely on the cached module and therefore when cleaning the resources, re importing those links is not enough. Instead, we are now treating the run-script as a separate command that we run during running the migration so that resources are isolated and loaded according to the need of each script themselves
This commit is contained in:
Adrien de Peretti
2025-01-23 17:33:50 +01:00
committed by GitHub
parent 6e5912612c
commit eace10e66b
3 changed files with 76 additions and 36 deletions

View File

@@ -204,6 +204,16 @@ function buildLocalCommands(cli, isLocalProject) {
})
),
})
.command({
command: "db:migrate:scripts",
desc: "Run all migration scripts",
handler: handlerP(
getCommandHandler("db/run-scripts", (args, cmd) => {
process.env.NODE_ENV = process.env.NODE_ENV || `development`
return cmd(args)
})
),
})
.command({
command: "db:rollback [modules...]",
desc: "Rollback last batch of executed migrations for a given module",