Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Delete old ephemeral links

Steven Teycdbc91b40612
diff --git a/apps/web/scripts/delete-old-links.ts b/apps/web/scripts/delete-old-links.ts
new file mode 100644
index 0000000000..723f75fe1a
--- /dev/null
+++ b/apps/web/scripts/delete-old-links.ts
@@ -0,0 +1,24 @@
+import { prisma } from "@dub/prisma";
+import "dotenv-flow/config";
+
+async function main() {
+ const links = await prisma.link.findMany({
+ where: {
+ domain: "sms.cal.com",
+ },
+ select: {
+ id: true,
+ domain: true,
+ key: true,
+ createdAt: true,
+ },
+ orderBy: {
+ createdAt: "asc",
+ },
+ take: 500,
+ });
+
+ console.table(links);
+}
+
+main();
diff --git a/packages/prisma/schema/domain.prisma b/packages/prisma/schema/domain.prisma
index 62e8de01b5..a9e4084b52 100644
--- a/packages/prisma/schema/domain.prisma
+++ b/packages/prisma/schema/domain.prisma
@@ -9,6 +9,7 @@ model Domain {
archived Boolean @default(false)
lastChecked DateTime @default(now())
logo String?
+ linkRetentionMonths Int?
appleAppSiteAssociation Json?
assetLinks Json?
project Project? @relation(fields: [projectId], references: [id], onDelete: Cascade)
diff --git a/packages/prisma/schema/link.prisma b/packages/prisma/schema/link.prisma
index a19c4a54d1..6360e0079e 100644
--- a/packages/prisma/schema/link.prisma
+++ b/packages/prisma/schema/link.prisma
@@ -90,4 +90,5 @@ model Link {
@@index([programId, partnerId]) // for getting a referral link (programId + partnerId)
@@index(folderId) // used in /api/folders
@@index(userId) // for relation to User table
+ @@index([domain, createdAt]) // used for deleting old links
}