Skip to content

Commit

Permalink
fix(prisma): improve the seed command
Browse files Browse the repository at this point in the history
  • Loading branch information
devsargam committed Mar 31, 2024
1 parent 3405f9f commit 00b842a
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
import db from '../src/db/index';

async function main() {
await db.user.createMany({
data: [
{
id: '2',
email: 'testuser',
name: 'Test User 1',
disableDrm: false,
},
{
id: '1',
email: 'testuser2',
name: 'Test User 2',
disableDrm: false,
},
],
await db.user.upsert({
where: {
id: '2',
email: 'testuser',
},
create: {
id: '2',
email: 'testuser',
name: 'Test User 1',
disableDrm: false,
},
update: {},
});

await db.user.upsert({
where: {
id: '1',
email: 'testuser2',
},
create: {
id: '1',
email: 'testuser2',
name: 'Test User 2',
disableDrm: false,
},
update: {},
});

if (await db.course.findMany()) {
console.error('DB is already seeded!');
process.exit(0);
}

await db.course.createMany({
data: [
{
Expand Down

0 comments on commit 00b842a

Please sign in to comment.