User registration.

This commit is contained in:
Daniel
2023-01-31 15:06:56 +03:30
parent 4cd0e8799c
commit 882bbd64d1
12 changed files with 231 additions and 11 deletions
@@ -0,0 +1,32 @@
-- CreateTable
CREATE TABLE "User" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"username" TEXT NOT NULL,
"password" TEXT NOT NULL,
CONSTRAINT "User_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Collection" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
CONSTRAINT "Collection_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "UserAndCollection" (
"userId" TEXT NOT NULL,
"collectionId" TEXT NOT NULL,
"role" TEXT NOT NULL,
CONSTRAINT "UserAndCollection_pkey" PRIMARY KEY ("userId","collectionId")
);
-- AddForeignKey
ALTER TABLE "UserAndCollection" ADD CONSTRAINT "UserAndCollection_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "UserAndCollection" ADD CONSTRAINT "UserAndCollection_collectionId_fkey" FOREIGN KEY ("collectionId") REFERENCES "Collection"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
+3
View File
@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "postgresql"
+37
View File
@@ -0,0 +1,37 @@
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id String @id @default(cuid())
name String
username String
password String
collections UserAndCollection[]
}
model Collection {
id String @id @default(cuid())
name String
users UserAndCollection[]
}
model UserAndCollection {
user User @relation(fields: [userId], references: [id])
userId String
collection Collection @relation(fields: [collectionId], references: [id])
collectionId String
role String
@@id([userId, collectionId])
}