Add dev db reset command
This commit is contained in:
@@ -56,6 +56,17 @@ const handlers: Record<string, (migrator: Migrator) => Promise<HandlerResult>> =
|
||||
}
|
||||
|
||||
return { message: `rolled back ${count} migration(s)` };
|
||||
},
|
||||
"reset": async function (migrator: Migrator) {
|
||||
if (env.NODE_ENV !== "development") throw new Error("Development only command");
|
||||
|
||||
if (typeof handlers["rollback"] !== "function") throw new Error("Missing rollback handler");
|
||||
await handlers["rollback"](migrator);
|
||||
|
||||
if (typeof handlers["latest"] !== "function") throw new Error("Missing latest handler");
|
||||
await handlers["latest"](migrator);
|
||||
|
||||
return { message: "database fully reset" };
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user