waiterjan-technical-task/prisma/schema.prisma

72 lines
2.0 KiB
Plaintext

//////////////////////////////////////////////////////////////////////////////////////////////
// DO NOT MODIFY THIS FILE //
// This file is automatically generated by ZenStack CLI and should not be manually updated. //
//////////////////////////////////////////////////////////////////////////////////////////////
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
generator typegraphql {
provider = "typegraphql-prisma-nestjs"
output = "../src/type-graphql/generated"
}
/// @@allow('create,read', true)
/// @@allow('update', auth() == this && future().email == email)
model User {
id Int @id() @default(autoincrement())
email String @unique()
/// @omit
password String
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
role UsersRoles[]
product Product[]
}
model Role {
id Int @id() @default(autoincrement())
name String @unique()
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
permission Permission[]
user UsersRoles[]
}
model Permission {
id Int @id() @default(autoincrement())
name String @unique()
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
role Role @relation(fields: [roleId], references: [id])
roleId Int
}
model UsersRoles {
user User @relation(fields: [userId], references: [id])
userId Int
role Role @relation(fields: [roleId], references: [id])
roleId Int
assignedAt DateTime @default(now())
assignedBy String
@@id([userId, roleId])
}
/// @@allow('all', auth() == author)
/// @@allow('read', auth() != null && published)
model Product {
id String @id() @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt()
title String
published Boolean @default(false)
author User @relation(fields: [authorId], references: [id])
authorId Int
}