From 5aa8ca01e94141d2c26c33df66eabb2249f340e1 Mon Sep 17 00:00:00 2001 From: Guillaume Dorce Date: Wed, 17 Aug 2022 19:10:23 +0200 Subject: [PATCH] add env config, and create base schema for prisma --- .env.example | 1 + .gitignore | 3 ++- prisma/schema.prisma | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..5157602 --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +DATABASE_URL='' \ No newline at end of file diff --git a/.gitignore b/.gitignore index fee232a..bb24732 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,5 @@ dist-ssr *.sw? *.sqlite -*.db \ No newline at end of file +*.db +.env \ No newline at end of file diff --git a/prisma/schema.prisma b/prisma/schema.prisma index e69de29..edd1865 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -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]) +}