// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init

generator client {
        provider        = "prisma-client-js"
        previewFeatures = ["relationJoins"]
        output          = "../node_modules/.prisma/client"
}

datasource db {
        provider = "postgresql"
        url      = env("DATABASE_URL")
}

model User {
        id       String   @id @default(uuid())
        username String   @unique @db.VarChar(50)
        email    String   @unique
        password String
        files    File[]
        Folder   Folder[]
}

model File {
        id         String   @id @default(uuid())
        name       String   @db.VarChar(255)
        url        String
        size       Int
        mimetype   String
        createdAt  DateTime @default(now())
        modifiedAt DateTime @default("2020-03-19T14:21:00+02:00")
        owner      User?    @relation(fields: [ownerId], references: [id])
        ownerId    String?
        folder     Folder?  @relation(fields: [folderId], references: [id])
        folderId   String?
}

model Folder {
        id                String   @id @default(uuid())
        name              String   @db.VarChar(255)
        createdAt         DateTime @default(now())
        modification_date DateTime @default(now())
        File              File[]
        owner             User?    @relation(fields: [owner_user_id], references: [id])
        owner_user_id     String?
        parentId          String?
        parent            Folder?  @relation("ParentDirectory", fields: [parentId], references: [id])
        Directories       Folder[] @relation("ParentDirectory")
}

model Session {
        id        String   @id
        sid       String   @unique
        data      String
        expiresAt DateTime
}
