added migrations to git

This commit is contained in:
johnyeo
2026-05-18 20:48:51 +01:00
parent 5018cca2ce
commit 36e530dee7
22 changed files with 8541 additions and 76 deletions

46
scripts/db/index.ts Normal file
View File

@@ -0,0 +1,46 @@
import { cmdHelp } from "./commands/help.ts";
import { cmdGenerate } from "./commands/generate.ts";
import { cmdMigrate } from "./commands/migrate.ts";
import { cmdMarkApplied } from "./commands/markApplied.ts";
import { cmdRebase } from "./commands/rebase.ts";
import { parseEnv } from "./helpers/env.ts";
async function main(): Promise<void> {
const sub = process.argv[2];
const rest = process.argv.slice(3);
if (!sub || sub === "help" || sub === "--help" || sub === "-h") {
cmdHelp();
return;
}
switch (sub) {
case "generate":
await cmdGenerate();
return;
case "migrate":
await cmdMigrate(parseEnv(rest), {
dryRun: false,
bootstrap: rest.includes("--bootstrap"),
});
return;
case "migrate:dry":
await cmdMigrate(parseEnv(rest), {
dryRun: true,
bootstrap: rest.includes("--bootstrap"),
});
return;
case "mark-applied":
await cmdMarkApplied(parseEnv(rest));
return;
case "rebase":
await cmdRebase();
return;
default:
console.error(`unknown subcommand: ${sub}`);
cmdHelp();
process.exit(2);
}
}
await main();