Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"format": "biome format --write .",
"postinstall": "prisma generate"
},
"prisma": {
"seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} prisma/seed.ts"
},
"dependencies": {
"@prisma/client": "^5.11.0",
"@radix-ui/react-dialog": "^1.1.1",
Expand Down
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ generator client {

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
url = "postgres://test:test@localhost:5432/test"
}


Expand Down
19 changes: 19 additions & 0 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { ElectionStatus, PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();
const candidates: string[] = ["Candidate_1, Candidate_2, Candidate_3"];

async function main() {
await prisma.election.create({
data: {
id: "824a-a25251e23013",
name: "Election 4",
status: ElectionStatus.FINISHED,
candidates: {
create: candidates.map((name) => ({ name })),
},
},
});
}
main().then(async () => {
await prisma.$disconnect();
});