41 lines
1.5 KiB
TypeScript
41 lines
1.5 KiB
TypeScript
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import Database from "better-sqlite3";
|
|
|
|
// ── Paths ─────────────────────────────────────────────────────────────────────
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
const DB_PATH = path.join(__dirname, "pipeline.db");
|
|
|
|
// ── Main ──────────────────────────────────────────────────────────────────────
|
|
|
|
function main(): void {
|
|
const mode = process.argv[2];
|
|
|
|
if (!mode || (mode !== "round1" && mode !== "all")) {
|
|
console.error("Usage: pnpm db:reset round1 | all");
|
|
console.error(" round1 — delete all round1 sub-stage rows");
|
|
console.error(" all — delete all run_status rows except reverse_link");
|
|
process.exit(1);
|
|
}
|
|
|
|
const db = new Database(DB_PATH);
|
|
|
|
let result: { changes: number };
|
|
|
|
if (mode === "round1") {
|
|
result = db
|
|
.prepare("DELETE FROM run_status WHERE stage LIKE 'round1%'")
|
|
.run();
|
|
console.log(`Deleted ${result.changes} round1 rows from run_status`);
|
|
} else {
|
|
result = db
|
|
.prepare("DELETE FROM run_status WHERE stage NOT IN ('reverse_link')")
|
|
.run();
|
|
console.log(`Deleted ${result.changes} rows from run_status`);
|
|
}
|
|
|
|
db.close();
|
|
}
|
|
|
|
main();
|