Skip to content

Commit ca61022

Browse files
authored
Merge pull request #74 from GeneralMagicio/sync-prisma-with-DB
sync Prisma schema with DB
2 parents 3e96e4e + a6d0d31 commit ca61022

File tree

3 files changed

+16
-20
lines changed

3 files changed

+16
-20
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
"start:dev": "nest start --watch",
1414
"start:debug": "nest start --debug --watch",
1515
"start:prod": "node dist/main",
16-
"migration:local": "npx prisma migrate dev --create-only",
16+
"migration:generate": "npx prisma migrate dev --create-only",
1717
"migration:prod": "npx prisma migrate deploy",
18+
"db:pull": "npx prisma db pull",
1819
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
1920
"test": "jest",
2021
"test:watch": "jest --watch",
@@ -87,4 +88,4 @@
8788
"testEnvironment": "node"
8889
},
8990
"packageManager": "yarn@1.22.19+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447"
90-
}
91+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Please do not edit this file manually
22
# It should be added in your version-control system (e.g., Git)
3-
provider = "postgresql"
3+
provider = "postgresql"

prisma/schema.prisma

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
// This is your Prisma schema file,
2-
// learn more about it in the docs: https://pris.ly/d/prisma-schema
3-
4-
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
5-
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
6-
71
generator client {
82
provider = "prisma-client-js"
93
}
@@ -21,37 +15,38 @@ model User {
2115
pollsCreatedCount Int @default(0)
2216
pollsParticipatedCount Int @default(0)
2317
createdPolls Poll[] @relation("PollAuthor")
24-
votes Vote[]
2518
actions UserAction[]
19+
votes Vote[]
2620
}
2721

2822
model UserAction {
2923
id Int @id @default(autoincrement())
3024
userId Int
3125
pollId Int
3226
type ActionType
33-
user User @relation(fields: [userId], references: [id])
34-
poll Poll @relation(fields: [pollId], references: [pollId], onDelete: Cascade)
3527
createdAt DateTime @default(now())
3628
updatedAt DateTime @default(now()) @updatedAt
29+
poll Poll @relation(fields: [pollId], references: [pollId], onDelete: Cascade)
30+
user User @relation(fields: [userId], references: [id])
3731
}
3832

3933
model Poll {
40-
pollId Int @id @default(autoincrement())
34+
pollId Int @id @default(autoincrement())
4135
authorUserId Int
4236
title String
4337
description String?
4438
options String[]
45-
creationDate DateTime @default(now())
39+
creationDate DateTime @default(now())
4640
startDate DateTime
4741
endDate DateTime
4842
tags String[]
49-
isAnonymous Boolean @default(false)
50-
participantCount Int @default(0)
43+
isAnonymous Boolean @default(false)
44+
participantCount Int @default(0)
5145
voteResults Json
52-
author User @relation("PollAuthor", fields: [authorUserId], references: [id])
53-
votes Vote[]
46+
searchVector Unsupported("tsvector")?
47+
author User @relation("PollAuthor", fields: [authorUserId], references: [id])
5448
userAction UserAction[]
49+
votes Vote[]
5550
}
5651

5752
model Vote {
@@ -60,10 +55,10 @@ model Vote {
6055
pollId Int
6156
votingPower Int
6257
weightDistribution Json
63-
quadraticWeights Json? // DO NOT INSERT INTO THIS, THIS IS A GENERATED COLUMN
6458
proof String
65-
user User @relation(fields: [userId], references: [id])
59+
quadraticWeights Json? @default(dbgenerated("calculate_quadratic_weights(\"weightDistribution\")"))
6660
poll Poll @relation(fields: [pollId], references: [pollId], onDelete: Cascade)
61+
user User @relation(fields: [userId], references: [id])
6762
}
6863

6964
enum ActionType {

0 commit comments

Comments
 (0)