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.

Update migrate-integrations.ts

Steven Tey94660fbd0bc7
diff --git a/apps/web/scripts/migrate-integrations.ts b/apps/web/scripts/migrate-integrations.ts
index 4e4bc5bdf4..9aa9d9542f 100644
--- a/apps/web/scripts/migrate-integrations.ts
+++ b/apps/web/scripts/migrate-integrations.ts
@@ -39,33 +39,44 @@ async function main() {
// ----------------------------
// Step 2: Migrate OAuthAuthorizedApp to InstalledIntegration
- // const authorizedApps = await prisma.oAuthAuthorizedApp.findMany({
- // select: {
- // id: true,
- // userId: true,
- // clientId: true,
- // projectId: true,
- // createdAt: true,
- // oAuthApp: {
- // select: {
- // id: true,
- // },
- // },
- // },
- // });
+ const authorizedApps = await prisma.oAuthAuthorizedApp.findMany({
+ select: {
+ id: true,
+ userId: true,
+ clientId: true,
+ projectId: true,
+ createdAt: true,
+ oAuthApp: {
+ select: {
+ integration: {
+ select: {
+ id: true,
+ },
+ },
+ },
+ },
+ },
+ });
- // for (const authorizedApp of authorizedApps) {
- // await prisma.installedIntegration.create({
- // data: {
- // id: authorizedApp.id,
- // integrationId: authorizedApp.oAuthApp.id,
- // projectId: authorizedApp.projectId,
- // userId: authorizedApp.userId,
- // createdAt: authorizedApp.createdAt,
- // updatedAt: authorizedApp.createdAt,
- // },
- // });
- // }
+ for (const authorizedApp of authorizedApps) {
+ if (!authorizedApp.oAuthApp.integration) {
+ console.log(
+ `Integration not found for authorized app ${authorizedApp.id}`,
+ );
+ continue;
+ }
+
+ await prisma.installedIntegration.create({
+ data: {
+ id: authorizedApp.id,
+ integrationId: authorizedApp.oAuthApp.integration.id,
+ projectId: authorizedApp.projectId,
+ userId: authorizedApp.userId,
+ createdAt: authorizedApp.createdAt,
+ updatedAt: authorizedApp.createdAt,
+ },
+ });
+ }
}
main();