33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { PrismaClient } from '@prisma/client';
|
|
const p = new PrismaClient();
|
|
|
|
async function main() {
|
|
const tasks = await p.task.findMany({
|
|
where: { source: 'AGENT_AVGUST' },
|
|
select: { id: true, title: true, dueDate: true },
|
|
});
|
|
console.log(`Tasks AGENT_AVGUST: ${tasks.length}`);
|
|
for (const t of tasks) console.log(` - ${t.title} (${t.dueDate?.toISOString().slice(0, 10) ?? 'no date'})`);
|
|
|
|
if (tasks.length > 0) {
|
|
const { count } = await p.reminder.deleteMany({ where: { task: { source: 'AGENT_AVGUST' } } });
|
|
console.log(`Reminders deleted: ${count}`);
|
|
const del = await p.task.deleteMany({ where: { source: 'AGENT_AVGUST' } });
|
|
console.log(`Tasks deleted: ${del.count}`);
|
|
}
|
|
|
|
const reminders = await p.reminder.findMany({
|
|
where: { source: 'AGENT_AVGUST' },
|
|
select: { id: true, customMessage: true },
|
|
});
|
|
if (reminders.length > 0) {
|
|
console.log(`Standalone reminders: ${reminders.length}`);
|
|
await p.reminder.deleteMany({ where: { source: 'AGENT_AVGUST' } });
|
|
console.log('Deleted');
|
|
}
|
|
|
|
console.log('Cleanup done');
|
|
}
|
|
|
|
main().finally(() => p.$disconnect());
|