feat(medusa-cli): Allow to revert migrations from the CLI (#1353)
This commit is contained in:
1 parent
b478b10438
commit
012513b6a1
2 files changed
+7
-2
No files matched your search
@@ -166,11 +166,11 @@ function buildLocalCommands(cli, isLocalProject) {
|
|||||||
})
|
})
|
||||||
.command({
|
.command({
|
||||||
command: `migrations [action]`,
|
command: `migrations [action]`,
|
||||||
desc: `Migrate the database to the most recent version.`,
|
desc: `Manage migrations from the core and your own project`,
|
||||||
builder: {
|
builder: {
|
||||||
action: {
|
action: {
|
||||||
demand: true,
|
demand: true,
|
||||||
choices: ["run", "show"],
|
choices: ["run", "revert", "show"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
handler: handlerP(
|
handler: handlerP(
|
||||||
|
|||||||
@@ -27,6 +27,11 @@ const t = async function({ directory }) {
|
|||||||
await connection.close()
|
await connection.close()
|
||||||
Logger.info("Migrations completed.")
|
Logger.info("Migrations completed.")
|
||||||
process.exit()
|
process.exit()
|
||||||
|
} else if (args[0] === "revert") {
|
||||||
|
await connection.undoLastMigration({ transaction: "all" })
|
||||||
|
await connection.close()
|
||||||
|
Logger.info("Migrations reverted.")
|
||||||
|
process.exit()
|
||||||
} else if (args[0] === "show") {
|
} else if (args[0] === "show") {
|
||||||
const unapplied = await connection.showMigrations()
|
const unapplied = await connection.showMigrations()
|
||||||
await connection.close()
|
await connection.close()
|
||||||
|
|||||||
Reference in new issue
Block a user