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.

add backfill script

Kiran K1b1415f03563
diff --git a/apps/web/scripts/backfill-domain-logo.ts b/apps/web/scripts/backfill-domain-logo.ts
new file mode 100644
index 0000000000..0cfc5d6d3e
--- /dev/null
+++ b/apps/web/scripts/backfill-domain-logo.ts
@@ -0,0 +1,38 @@
+import { prisma } from "@/lib/prisma";
+import "dotenv-flow/config";
+
+async function main() {
+ const workspaces = await prisma.project.findMany({
+ where: {
+ plan: {
+ not: "free",
+ },
+ logo: {
+ not: null,
+ },
+ },
+ take: 1000,
+ });
+
+ if (!workspaces.length) {
+ console.log("No workspaces found.");
+ return;
+ }
+
+ const updated = await Promise.all(
+ workspaces.map((workspace) =>
+ prisma.domain.updateMany({
+ where: {
+ projectId: workspace.id,
+ },
+ data: {
+ logo: workspace.logo,
+ },
+ }),
+ ),
+ );
+
+ console.log(`Updated ${updated.length} domains.`);
+}
+
+main();