Skip to content

Commit

Permalink
adding seeding script
Browse files Browse the repository at this point in the history
  • Loading branch information
Aayush-Agnihotri committed Dec 28, 2024
1 parent a4177b9 commit 4eb04a6
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 2 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ COPY . .
ENV NEXT_TELEMETRY_DISABLED=1

RUN npx prisma generate
RUN npx prisma db seed
RUN npm run build

# Production image, copy all the files and run next
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ services:
- '3000:3000'
env_file:
- .env
volumes:
- ./ca-certificate.crt:/app/ca-certificate.crt:ro
depends_on:
- ollama
networks:
Expand Down
158 changes: 158 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"prettier-plugin-tailwindcss": "^0.6.9",
"prisma": "^6.1.0",
"tailwindcss": "^3.4.1",
"ts-node": "^10.9.2",
"typescript": "^5.7.2"
},
"lint-staged": {
Expand Down
3 changes: 1 addition & 2 deletions scripts/prepopulateEmails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient();

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

async function main() {
for (const email of appDevEmails) {
Expand All @@ -12,7 +12,6 @@ async function main() {
update: {},
});
}
console.log(await prisma.email.findMany());
}

main()
Expand Down
11 changes: 11 additions & 0 deletions src/app/api/users/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@ import { NextResponse } from 'next/server';
import prisma from '@/prisma';

export async function GET() {
await prisma.email.upsert({
where: {
email: 'aa2328@cornell.edu',
},
update: {},
create: {
email: 'aa2328@cornell.edu',
},
});

const emails = await prisma.email.findMany();
const users = await prisma.user.findMany();

return NextResponse.json({ emails, users });
}

0 comments on commit 4eb04a6

Please sign in to comment.