mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
Allow seeding without forcing sync
This commit is contained in:
@@ -21,8 +21,7 @@ export const sync: CliCommand = (program) => {
|
||||
console.info("");
|
||||
if (stmts.length === 0) {
|
||||
console.info(c.yellow("No changes to sync"));
|
||||
process.exit(0);
|
||||
}
|
||||
} else {
|
||||
// @todo: currently assuming parameters aren't used
|
||||
const sql = stmts.map((d) => d.sql).join(";\n") + ";";
|
||||
|
||||
@@ -32,20 +31,6 @@ export const sync: CliCommand = (program) => {
|
||||
|
||||
console.info(`\n${c.dim(`Executed ${c.cyan(stmts.length)} statement(s)`)}`);
|
||||
console.info(`${c.green("Database synced")}`);
|
||||
|
||||
if (options.seed) {
|
||||
console.info(c.dim("\nExecuting seed..."));
|
||||
const seed = app.options?.seed;
|
||||
if (seed) {
|
||||
await app.options?.seed?.({
|
||||
...app.modules.ctx(),
|
||||
app: app,
|
||||
});
|
||||
console.info(c.green("Seed executed"));
|
||||
} else {
|
||||
console.info(c.yellow("No seed function provided"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (options.out) {
|
||||
const output = options.sql ? sql : JSON.stringify(stmts, null, 2);
|
||||
@@ -61,6 +46,22 @@ export const sync: CliCommand = (program) => {
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (options.seed) {
|
||||
console.info(c.dim("\nExecuting seed..."));
|
||||
const seed = app.options?.seed;
|
||||
if (seed) {
|
||||
await seed({
|
||||
...app.modules.ctx(),
|
||||
app: app,
|
||||
});
|
||||
console.info(c.green("Seed executed"));
|
||||
} else {
|
||||
console.info(c.yellow("No seed function provided"));
|
||||
}
|
||||
}
|
||||
|
||||
process.exit(0);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user