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 script to backfill workspace groups limit

Kiran K01ccbcf32d58
diff --git a/apps/web/scripts/partners/backfill-workspace-groups-limit.ts b/apps/web/scripts/partners/backfill-workspace-groups-limit.ts
new file mode 100644
index 0000000000..b12ceee0bb
--- /dev/null
+++ b/apps/web/scripts/partners/backfill-workspace-groups-limit.ts
@@ -0,0 +1,48 @@
+import { prisma } from "@dub/prisma";
+import { getCurrentPlan } from "@dub/utils";
+import "dotenv-flow/config";
+
+async function main() {
+ const workspaces = await prisma.project.findMany({
+ where: {
+ groupsLimit: 0,
+ plan: {
+ notIn: ["free", "pro"],
+ },
+ },
+ select: {
+ id: true,
+ slug: true,
+ plan: true,
+ groupsLimit: true,
+ },
+ take: 100,
+ });
+
+ if (workspaces.length === 0) {
+ console.log("No workspaces to update.");
+ return;
+ }
+
+ console.table(workspaces);
+ console.log(`Found ${workspaces.length} workspaces to update.`);
+
+ for (const workspace of workspaces) {
+ const plan = getCurrentPlan(workspace.plan);
+
+ await prisma.project.update({
+ where: {
+ id: workspace.id,
+ },
+ data: {
+ groupsLimit: plan.limits.groups!,
+ },
+ });
+
+ console.log(
+ `Updated ${workspace.slug} groups limit to ${plan.limits.groups}`,
+ );
+ }
+}
+
+main();