sinProject-Inc/talk

View on GitHub
prisma/schema.prisma

Summary

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

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

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

model AppSetting {
  id         Int      @id @default(autoincrement())
  created_at DateTime @default(now())
  updated_at DateTime @updatedAt
  key        String   @unique
  value      String
}

model Role {
  id         Int      @id @default(autoincrement())
  created_at DateTime @default(now())
  updated_at DateTime @updatedAt
  name       String   @unique
  users      User[]
}

enum Theme {
  system
  light
  dark
}

enum AvatarExtension {
  jpg
  jpeg
  png
}

model User {
  id               Int             @id @default(autoincrement())
  created_at       DateTime        @default(now())
  updated_at       DateTime        @updatedAt
  role_id          Int
  email            String          @unique
  theme            Theme           @default(system)
  avatar_extension AvatarExtension @default(png)
  role             Role            @relation(fields: [role_id], references: [id])
  auth_pin         AuthPin[]
  auth_token       AuthToken[]
}

model AuthToken {
  id         Int      @id @default(autoincrement())
  created_at DateTime @default(now())
  updated_at DateTime @updatedAt
  user_id    Int
  token      String   @unique
  user       User     @relation(fields: [user_id], references: [id])

  @@index(updated_at)
}

model AuthPin {
  id         Int      @id @default(autoincrement())
  created_at DateTime @default(now())
  updated_at DateTime @updatedAt
  user_id    Int      @unique
  pin_code   String   @unique
  user       User     @relation(fields: [user_id], references: [id])
}

model Locale {
  id         Int       @id @default(autoincrement())
  created_at DateTime  @default(now())
  updated_at DateTime  @updatedAt
  code       String    @unique
  language   String
  country    String
  emoji      String
  tests      Text[]
  sounds     Sound[]
  ChatLog    ChatLog[]
  Voice      Voice[]
}

model Text {
  id          Int          @id @default(autoincrement())
  created_at  DateTime     @default(now())
  updated_at  DateTime     @updatedAt
  locale_id   Int
  text        String       @db.VarChar(700)
  locale      Locale       @relation(fields: [locale_id], references: [id])
  TextToText1 TextToText[] @relation("TextToText1")
  TextToText2 TextToText[] @relation("TextToText2")

  @@unique([locale_id, text])
  @@index([locale_id])
}

model Sound {
  id         Int      @id @default(autoincrement())
  created_at DateTime @default(now())
  updated_at DateTime @updatedAt
  locale_id  Int
  sound_text String   @db.VarChar(700)
  locale     Locale   @relation(fields: [locale_id], references: [id])

  @@unique([locale_id, sound_text])
}

model TextToText {
  id         Int      @id @default(autoincrement())
  created_at DateTime @default(now())
  updated_at DateTime @updatedAt
  text_id_1  Int
  text_id_2  Int
  text_1     Text     @relation(name: "TextToText1", fields: [text_id_1], references: [id])
  text_2     Text     @relation(name: "TextToText2", fields: [text_id_2], references: [id])

  @@unique([text_id_1, text_id_2])
  @@index([text_id_1])
  @@index([text_id_2])
}

model Voice {
  id         Int      @id @default(autoincrement())
  created_at DateTime @default(now())
  updated_at DateTime @updatedAt
  name       String   @unique
  locale_id  Int
  target     String
  locale     Locale   @relation(fields: [locale_id], references: [id])
}

model ChatLog {
  id          Int      @id @default(autoincrement())
  created_at  DateTime @default(now())
  updated_at  DateTime @updatedAt
  room_id     String
  locale_code String
  name        String
  sender_id   Int
  message     String   @db.VarChar(700)
  locale      Locale   @relation(fields: [locale_code], references: [code])
}

model ChatMember {
  id               Int      @id @default(autoincrement())
  created_at       DateTime @default(now())
  updated_at       DateTime @updatedAt
  socket_id        String   @unique
  room_id          String
  name             String
  user_id          Int
  locale_code      String
  is_mobile_device Boolean
}

model SignInLog {
  id         Int      @id @default(autoincrement())
  created_at DateTime @default(now())
  updated_at DateTime @updatedAt
  ip_address String
  account    String
  success    Boolean
}