feat(db cleanup): added a cleanup for labels this checks daily

This commit is contained in:
2025-04-14 12:53:05 -05:00
parent d4edeb15d9
commit 450e5acd34
3 changed files with 31 additions and 20 deletions

View File

@@ -0,0 +1,23 @@
import { lt } from "drizzle-orm";
import { db } from "../../../database/dbclient.js";
import { prodlabels } from "../../../database/schema/prodLabels.js";
import { addDays } from "date-fns";
import { createLog } from "../../services/logger/logger.js";
export const deleteLabels = async () => {
/**
* Deletes labels older than 90 days from lst... all label data can be found in alpla prod.
*/
try {
await db
.delete(prodlabels)
.where(lt(prodlabels.upd_date, addDays(new Date(Date.now()), -90)));
} catch (error) {
createLog(
"error",
"labeling",
"ocp",
`Error deleting labels older than 90 days`
);
}
};