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]) +}