// Don't forget to tell Prisma about your edits to this file using
// `yarn rw prisma migrate dev` or `yarn rw prisma db push`.
// `migrate` is like committing while `push` is for prototyping.
// Read more about both here:
// https://www.prisma.io/docs/orm/prisma-migrate

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

generator client {
  provider      = "prisma-client-js"
  binaryTargets = "native"
}

// Define your own datamodels here and run `yarn redwood prisma migrate dev`
// to create migrations for them and apply to your dev DB.
// TODO: Please remove the following example:
model UserExample {
  id    Int     @id @default(autoincrement())
  email String  @unique
  name  String?
}

model User {
  id                  Int                @id @default(autoincrement())
  email               String             @unique
  firstName           String?
  lastName            String?
  hashedPassword      String?
  salt                String?
  resetToken          String?
  resetTokenExpiresAt DateTime?
  createdAt           DateTime           @default(now())
  updatedAt           DateTime           @updatedAt
  roles               String             @default("user")
  identites           Identity[]
  Nachhilfeangebot    Nachhilfeangebot[]
}

model Identity {
  id          Int      @id @default(autoincrement())
  provider    String
  uid         String
  userId      Int
  user        User     @relation(fields: [userId], references: [id])
  accessToken String?
  scope       String?
  lastLoginAt DateTime @default(now())
  createdAt   DateTime @default(now())
  updatedAt   DateTime @updatedAt

  @@unique([provider, uid])
  @@index(userId)
}

model Post {
  id        Int      @id @default(autoincrement())
  title     String
  body      String
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}

model Nachhilfeangebot {
  id           Int     @id @default(autoincrement())
  subject      String
  currentClass String
  cost         Decimal
  userId       Int
  user         User    @relation(fields: [userId], references: [id])
}
