-
Notifications
You must be signed in to change notification settings - Fork 2
/
pfp_seed.js
36 lines (31 loc) · 838 Bytes
/
pfp_seed.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const { PrismaClient } = require("@prisma/client");
const { clerkClient } = require("@clerk/nextjs");
const prisma = new PrismaClient();
async function updateImageUrls() {
const dbUsers = await clerkClient.users.getUserList({
limit: 250,
});
try {
for (const dbUser of dbUsers) {
if (dbUser.imageUrl) {
await prisma.user.update({
where: {
id: dbUser.id,
},
data: {
imageUrl: dbUser.imageUrl,
},
});
console.log(`Updated image URL for user ${dbUser.firstName} ${dbUser.lastName}.`);
}
}
console.log("Image URLs updated successfully.");
} catch (error) {
console.error("Error updating image URLs:", error);
} finally {
await prisma.$disconnect();
}
}
(async () => {
await updateImageUrls();
})();