Skip to content

Commit

Permalink
chore: loop one-by-one in seed script & upsert for fault intolerance
Browse files Browse the repository at this point in the history
  • Loading branch information
p6l-richard committed Jul 12, 2024
1 parent 44d8fd4 commit 105b440
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ import { PrismaClient } from "@prisma/client";
const devDb = new PrismaClient();

async function main() {
await devDb.filterOption.createMany({
data: filterOptions,
});
for (const filterOption of filterOptions) {
console.log(`attempting to upsert ${filterOption.fieldId}`);
await devDb.filterOption.upsert({
where: { fieldId: filterOption.fieldId },
create: filterOption,
update: filterOption,
});
console.log(`✅ {filterOption.fieldId} upserted`);
}
}

main()
Expand Down

0 comments on commit 105b440

Please sign in to comment.