Initial commit
This commit is contained in:
87
server/prisma/migrations/20201125185150-init/README.md
Normal file
87
server/prisma/migrations/20201125185150-init/README.md
Normal file
@@ -0,0 +1,87 @@
|
||||
# Migration `20201125185150-init`
|
||||
|
||||
This migration has been generated by Ryan Chenkie at 11/25/2020, 1:51:50 PM.
|
||||
You can check out the [state of the schema](./schema.prisma) after the migration.
|
||||
|
||||
## Database Steps
|
||||
|
||||
```sql
|
||||
CREATE TABLE "Link" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"description" TEXT NOT NULL,
|
||||
"url" TEXT NOT NULL,
|
||||
"postedById" INTEGER NOT NULL,
|
||||
|
||||
FOREIGN KEY ("postedById") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||
)
|
||||
|
||||
CREATE TABLE "User" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"name" TEXT NOT NULL,
|
||||
"email" TEXT NOT NULL,
|
||||
"password" TEXT NOT NULL
|
||||
)
|
||||
|
||||
CREATE TABLE "Vote" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"linkId" INTEGER NOT NULL,
|
||||
"userId" INTEGER NOT NULL,
|
||||
|
||||
FOREIGN KEY ("linkId") REFERENCES "Link"("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||
)
|
||||
|
||||
CREATE UNIQUE INDEX "User.email_unique" ON "User"("email")
|
||||
|
||||
CREATE UNIQUE INDEX "Vote.linkId_userId_unique" ON "Vote"("linkId", "userId")
|
||||
```
|
||||
|
||||
## Changes
|
||||
|
||||
```diff
|
||||
diff --git schema.prisma schema.prisma
|
||||
migration ..20201125185150-init
|
||||
--- datamodel.dml
|
||||
+++ datamodel.dml
|
||||
@@ -1,0 +1,37 @@
|
||||
+datasource db {
|
||||
+ provider = "sqlite"
|
||||
+ url = "***"
|
||||
+}
|
||||
+
|
||||
+generator client {
|
||||
+ provider = "prisma-client-js"
|
||||
+}
|
||||
+
|
||||
+model Link {
|
||||
+ id Int @id @default(autoincrement())
|
||||
+ createdAt DateTime @default(now())
|
||||
+ description String
|
||||
+ url String
|
||||
+ postedBy User @relation(fields: [postedById], references: [id])
|
||||
+ postedById Int
|
||||
+ votes Vote[]
|
||||
+}
|
||||
+
|
||||
+model User {
|
||||
+ id Int @id @default(autoincrement())
|
||||
+ name String
|
||||
+ email String @unique
|
||||
+ password String
|
||||
+ links Link[]
|
||||
+ votes Vote[]
|
||||
+}
|
||||
+
|
||||
+model Vote {
|
||||
+ id Int @id @default(autoincrement())
|
||||
+ link Link @relation(fields: [linkId], references: [id])
|
||||
+ linkId Int
|
||||
+ user User @relation(fields: [userId], references: [id])
|
||||
+ userId Int
|
||||
+
|
||||
+ @@unique([linkId, userId])
|
||||
+}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user