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 migration scripts

Kiran Kf12a925f6e86
diff --git a/apps/web/scripts/migrate-integrations.ts b/apps/web/scripts/migrate-integrations.ts
new file mode 100644
index 0000000000..6828d10063
--- /dev/null
+++ b/apps/web/scripts/migrate-integrations.ts
@@ -0,0 +1,42 @@
+import { prisma } from "@/lib/prisma";
+import "dotenv-flow/config";
+
+async function main() {
+ const oAuthApps = await prisma.oAuthApp.findMany({
+ select: {
+ name: true,
+ slug: true,
+ description: true,
+ readme: true,
+ developer: true,
+ website: true,
+ logo: true,
+ screenshots: true,
+ userId: true,
+ projectId: true,
+ verified: true,
+ createdAt: true,
+ updatedAt: true,
+ },
+ });
+
+ for (const oAuthApp of oAuthApps) {
+ const data = {
+ ...oAuthApp,
+ screenshots: oAuthApp.screenshots ? oAuthApp.screenshots : [],
+ };
+
+ // Create the integration
+ const integration = await prisma.integration.create({ data });
+
+ // Update the oAuthApp with the new integrationId
+ await prisma.oAuthApp.update({
+ where: { slug: oAuthApp.slug },
+ data: { integrationId: integration.id },
+ });
+ }
+
+ console.log("Migrated integrations");
+}
+
+main();