mirror of
https://github.com/fosrl/pangolin.git
synced 2026-05-07 00:39:53 +00:00
29 lines
814 B
TypeScript
29 lines
814 B
TypeScript
import { CommandModule } from "yargs";
|
|
import { db, certificates } from "@server/db";
|
|
|
|
type ClearCertificatesArgs = {};
|
|
|
|
export const clearCertificates: CommandModule<{}, ClearCertificatesArgs> = {
|
|
command: "clear-certificates",
|
|
describe: "Delete all entries from the certificates table",
|
|
builder: (yargs) => {
|
|
return yargs;
|
|
},
|
|
handler: async (argv: {}) => {
|
|
try {
|
|
console.log("Clearing all certificates from the database...");
|
|
|
|
const deleted = await db.delete(certificates).returning();
|
|
|
|
console.log(
|
|
`Deleted ${deleted.length} certificate(s) from the database`
|
|
);
|
|
|
|
process.exit(0);
|
|
} catch (error) {
|
|
console.error("Error:", error);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
};
|