add env config, and create base schema for prisma

This commit is contained in:
Guillaume Dorce 2022-08-17 19:10:23 +02:00
parent 789daa854a
commit 5aa8ca01e9
3 changed files with 39 additions and 1 deletions

1
.env.example Normal file
View File

@ -0,0 +1 @@
DATABASE_URL='<database_url>'

1
.gitignore vendored
View File

@ -25,3 +25,4 @@ dist-ssr
*.sqlite *.sqlite
*.db *.db
.env

View File

@ -0,0 +1,36 @@
generator client {
provider = "prisma-client-js"
previewFeatures = ["referentialIntegrity"]
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
referentialIntegrity = "prisma"
}
model User {
id Int @id @default(autoincrement())
firstname String
lastname String
email String
password String
posts Post[]
roleId Int
Role Role @relation(fields: [roleId], references: [id])
}
model Role {
id Int @id @default(autoincrement())
name String
users User[]
}
model Post {
id Int @id @default(autoincrement())
title String
content String
image String
authorId Int
author User @relation(fields: [authorId], references: [id])
}