Skip to content

Instantly share code, notes, and snippets.

@selcukcihan
Created May 17, 2023 07:36
Show Gist options
  • Save selcukcihan/e7bdc032fff43d30e175b785851ce328 to your computer and use it in GitHub Desktop.
Save selcukcihan/e7bdc032fff43d30e175b785851ce328 to your computer and use it in GitHub Desktop.
Schema for elections
// Define the schema for the election inspection application
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
// Define the schema models
model Country {
id Int @id @default(autoincrement())
name String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
cities City[]
electionBallotBoxes ElectionBallotBox[]
}
model City {
id Int @id @default(autoincrement())
name String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
districts District[]
country Country @relation(fields: [countryId], references: [id])
countryId Int
}
model District {
id Int @id @default(autoincrement())
name String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
ballotBoxes BallotBox[]
city City @relation(fields: [cityId], references: [id])
cityId Int
}
model BallotBox {
id Int @id @default(autoincrement())
name String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
district District @relation(fields: [districtId], references: [id])
districtId Int
votes Vote[]
}
model Party {
id Int @id @default(autoincrement())
name String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
votes Vote[]
}
model Vote {
id Int @id @default(autoincrement())
count Int
voidCount Int
noShowCount Int
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
ballotBox BallotBox @relation(fields: [ballotBoxId], references: [id])
ballotBoxId Int
party Party? @relation(fields: [partyId], references: [id])
partyId Int?
// Add user permissions and authorization fields as needed
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment