-
-
Notifications
You must be signed in to change notification settings - Fork 215
Open
Description
Hey everyone,
I'm thinking about implementing a cleanup process for old email bodies, since our database is growing significantly due to storing all message content and attachments.
Do you have any recommendations for how to approach this? Or maybe a better solution based on typical project structures?
At the moment, I'm running a SQL query via cron just to get things working in my environment, but I plan to eventually turn this into a proper feature.
Thanks again!
async function cleanupEmailBodies() {
const result = await db.$executeRaw`
UPDATE "Email"
SET "text" = NULL,
"html" = NULL
WHERE "createdAt" < NOW() - INTERVAL '90 days'
AND ("text" IS NOT NULL OR "html" IS NOT NULL);
`;
console.log(`[Cleanup] Emails cleaned: ${result}`);
}
Metadata
Metadata
Assignees
Labels
No labels