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 persist-customer-avatars.ts

Steven Tey12c8a69a0884
diff --git a/apps/web/scripts/persist-customer-avatars.ts b/apps/web/scripts/persist-customer-avatars.ts
index db2fd365e3..c764a92ad2 100644
--- a/apps/web/scripts/persist-customer-avatars.ts
+++ b/apps/web/scripts/persist-customer-avatars.ts
@@ -28,25 +28,32 @@ async function main() {
}
const finalCustomerAvatar = `${R2_URL}/customers/${customer.id}/avatar_${nanoid(7)}`;
- await storage.upload(
- finalCustomerAvatar.replace(`${R2_URL}/`, ""),
- customer.avatar,
- {
- width: 128,
- height: 128,
- },
- );
-
- const updatedCustomer = await prisma.customer.update({
- where: { id: customer.id },
- data: {
- avatar: finalCustomerAvatar,
- },
- });
-
- console.log(
- `Updated customer ${customer.id} to ${updatedCustomer.avatar}`,
- );
+ try {
+ await storage.upload(
+ finalCustomerAvatar.replace(`${R2_URL}/`, ""),
+ customer.avatar,
+ {
+ width: 128,
+ height: 128,
+ },
+ );
+
+ const updatedCustomer = await prisma.customer.update({
+ where: { id: customer.id },
+ data: {
+ avatar: finalCustomerAvatar,
+ },
+ });
+
+ console.log(
+ `Updated customer ${customer.id} to ${updatedCustomer.avatar}`,
+ );
+ } catch (error) {
+ console.log(
+ `Error updating customer ${customer.id} with avatar ${customer.avatar}`,
+ );
+ console.error(error);
+ }
}),
);