Feat(medusa, cli): plugin db generate (#10988)

RESOLVES FRMW-2875

**What**
Allow to generate migration for plugins. Migration generation defer from project migration generation and therefore we choose to separate responsibility entirely.

The flow is fairly simple, the user run `npx medusa plugin:db:generate` and the script will scan for all available modules in the plugins, gather their models information and generate the appropriate migrations and snapshot (for later generation)

Co-authored-by: Harminder Virk <1706381+thetutlage@users.noreply.github.com>
This commit is contained in:
Adrien de Peretti
2025-01-17 13:05:46 +01:00
committed by GitHub
parent 5582bd2038
commit 0cfaab5bb1
9 changed files with 272 additions and 1 deletions

View File

@@ -238,6 +238,16 @@ function buildLocalCommands(cli, isLocalProject) {
})
),
})
.command({
command: "plugin:db:generate",
desc: "Generate migrations for a given module",
handler: handlerP(
getCommandHandler("plugin/db/generate", (args, cmd) => {
process.env.NODE_ENV = process.env.NODE_ENV || `development`
return cmd(args)
})
),
})
.command({
command: "db:sync-links",
desc: "Sync database schema with the links defined by your application and Medusa core",