cal/packages/prisma/delete-app.ts
Omar López 037410aea7
One jest to rule them all (#3957)
* WIP

* Consolidates jest deps

* Test fixes

* Moves jest to root

* Test fixes

* Update CalendarService.test.ts

* Cleanup

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-08-29 22:33:53 +00:00

36 lines
723 B
TypeScript

import prisma from ".";
// TODO: Put some restrictions here to run it on local DB only.
// Production DB currently doesn't support app deletion
async function main() {
const appId = process.argv[2];
try {
await prisma.app.delete({
where: {
slug: appId,
},
});
await prisma.credential.deleteMany({
where: {
appId: appId,
},
});
console.log(`Deleted app from DB: '${appId}'`);
} catch (e) {
if (e.code === "P2025") {
console.log(`App '${appId}' already deleted from DB`);
return;
}
throw e;
}
}
main()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});