Skip to content

Commit 4eb04a6

Browse files
adding seeding script
1 parent a4177b9 commit 4eb04a6

File tree

6 files changed

+174
-2
lines changed

6 files changed

+174
-2
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ COPY . .
2525
ENV NEXT_TELEMETRY_DISABLED=1
2626

2727
RUN npx prisma generate
28+
RUN npx prisma db seed
2829
RUN npm run build
2930

3031
# Production image, copy all the files and run next

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ services:
1010
- '3000:3000'
1111
env_file:
1212
- .env
13+
volumes:
14+
- ./ca-certificate.crt:/app/ca-certificate.crt:ro
1315
depends_on:
1416
- ollama
1517
networks:

package-lock.json

Lines changed: 158 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"prettier-plugin-tailwindcss": "^0.6.9",
4141
"prisma": "^6.1.0",
4242
"tailwindcss": "^3.4.1",
43+
"ts-node": "^10.9.2",
4344
"typescript": "^5.7.2"
4445
},
4546
"lint-staged": {

scripts/prepopulateEmails.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { PrismaClient } from '@prisma/client';
22

33
const prisma = new PrismaClient();
44

5-
const appDevEmails = ['aa2328@cornell.edu'];
5+
const appDevEmails = ['a@cornell.edu', 'b@cornell.edu', 'c@cornell.edu'];
66

77
async function main() {
88
for (const email of appDevEmails) {
@@ -12,7 +12,6 @@ async function main() {
1212
update: {},
1313
});
1414
}
15-
console.log(await prisma.email.findMany());
1615
}
1716

1817
main()

src/app/api/users/route.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@ import { NextResponse } from 'next/server';
22
import prisma from '@/prisma';
33

44
export async function GET() {
5+
await prisma.email.upsert({
6+
where: {
7+
email: 'aa2328@cornell.edu',
8+
},
9+
update: {},
10+
create: {
11+
email: 'aa2328@cornell.edu',
12+
},
13+
});
14+
515
const emails = await prisma.email.findMany();
616
const users = await prisma.user.findMany();
17+
718
return NextResponse.json({ emails, users });
819
}

0 commit comments

Comments
 (0)