Skip to content

Commit

Permalink
πŸ†•πŸ”· prisma orm
Browse files Browse the repository at this point in the history
  • Loading branch information
jrCleber committed Dec 9, 2023
1 parent 88f2d1b commit a2474ed
Showing 1 changed file with 202 additions and 0 deletions.
202 changes: 202 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
// β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
// β”‚ @author jrCleber β”‚
// β”‚ @filename message.model.ts β”‚
// β”‚ Developed by: Cleber Wilson β”‚
// β”‚ Creation date: Dez 02, 2023 β”‚
// β”‚ Contact: [email protected] β”‚
// β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
// β”‚ @copyright Β© Cleber Wilson 2022. All rights reserved. β”‚
// β”‚ Licensed under the Apache License, Version 2.0 β”‚
// β”‚ β”‚
// β”‚ @license "https://github.com/code-chat-br/whatsapp-api/blob/main/LICENSE" β”‚
// β”‚ β”‚
// β”‚ You may not use this file except in compliance with the License. β”‚
// β”‚ You may obtain a copy of the License at β”‚
// β”‚ β”‚
// β”‚ http://www.apache.org/licenses/LICENSE-2.0 β”‚
// β”‚ β”‚
// β”‚ Unless required by applicable law or agreed to in writing, software β”‚
// β”‚ distributed under the License is distributed on an "AS IS" BASIS, β”‚
// β”‚ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. β”‚
// β”‚ β”‚
// β”‚ See the License for the specific language governing permissions and β”‚
// β”‚ limitations under the License. β”‚
// β”‚ β”‚ β”‚
// β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
// β”‚ @important β”‚
// β”‚ For any future changes to the code in this file, it is recommended to β”‚
// β”‚ contain, together with the modification, the information of the developer β”‚
// β”‚ who changed it and the date of modification. β”‚
// β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

// 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 = "postgresql"
url = env("DATABASE_URL")
}

enum InstanceConnectionStatus {
ONLINE
OFFLINE
}

model Instance {
id Int @id @default(autoincrement())
name String @unique @db.VarChar(255)
description String? @db.VarChar(255)
connectionStatus InstanceConnectionStatus? @default(OFFLINE)
ownerJid String? @unique @db.VarChar(100)
profilePicUrl String? @db.VarChar(500)
createdAt DateTime? @default(now()) @db.Date
updatedAt DateTime? @updatedAt @db.Date
Auth Auth?
Chat Chat[]
Contact Contact[]
Webhook Webhook?
Typebot Typebot?
ActivityLogs ActivityLogs[]
Message Message[]
}

model Auth {
id Int @id @default(autoincrement())
token String @unique
createdAt DateTime? @default(now()) @db.Date
updatedAt DateTime? @updatedAt @db.Date
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
instanceId Int @unique @db.Integer
}

enum MessageSource {
ios
android
web
}

enum DeviceMessage {
ios
android
web
}

model Message {
id Int @id @default(autoincrement())
keyId String @db.VarChar(100)
keyRemoteJid String @db.VarChar(100)
keyFromMe Boolean @db.Boolean
keyParticipant String? @db.VarChar(100)
pushName String? @db.VarChar(100)
messageType String @db.VarChar(100)
content Json @db.JsonB
messageTimestamp Int @db.Integer
device DeviceMessage
isGroup Boolean? @db.Boolean
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
instanceId Int
TypebotSession TypebotSession? @relation(fields: [typebotSessionId], references: [id], onDelete: Cascade)
typebotSessionId Int?
MessageUpdate MessageUpdate[]
Media Media?
@@index([keyId], name: "keyId")
}

model Media {
id Int @id @default(autoincrement())
fileName String @unique @db.VarChar(500)
type String @db.VarChar(100)
mimetype String @db.VarChar(100)
createdAt DateTime? @default(now()) @db.Date
Message Message @relation(fields: [messageId], references: [id], onDelete: Cascade)
messageId Int @unique
}

model MessageUpdate {
id Int @id @default(autoincrement())
dateTime DateTime @db.Date
status String @db.VarChar(30)
Message Message @relation(fields: [messageId], references: [id], onDelete: Cascade)
messageId Int
}

model Chat {
id Int @id @default(autoincrement())
remoteJid String @db.VarChar(100)
createdAt DateTime? @default(now()) @db.Date
updatedAt DateTime? @updatedAt @db.Date
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
instanceId Int
}

model Contact {
id Int @id @default(autoincrement())
remoteJid String @db.VarChar(100)
pushName String? @db.VarChar(100)
profilePicUrl String? @db.VarChar(500)
createdAt DateTime? @default(now()) @db.Date
updatedAt DateTime? @updatedAt @db.Date
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
instanceId Int
}

model Webhook {
id Int @id @default(autoincrement())
url String @db.VarChar(500)
enabled Boolean? @default(true) @db.Boolean
events Json? @db.JsonB
createdAt DateTime? @default(now()) @db.Date
updatedAt DateTime @updatedAt @db.Date
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
instanceId Int @unique
}

model Typebot {
id Int @id @default(autoincrement())
publicId String @db.VarChar(200)
typebotUrl String @db.VarChar(500)
enabled Boolean? @default(true) @db.Boolean
enableGroup Boolean? @default(false) @db.Boolean
createdAt DateTime? @default(now()) @db.Date
updatedAt DateTime? @updatedAt @db.Date
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
instanceId Int @unique
TypebotSession TypebotSession[]
}

enum TypebotSessionStatus {
open
closed
paused
}

model TypebotSession {
id Int @id @default(autoincrement())
sessionId String @unique @db.VarChar(200)
remoteJid String @db.VarChar(100)
status TypebotSessionStatus @default(open)
Typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade)
typebotId Int
Message Message[]
}

enum StartConversationAs {
open
pending
}

model ActivityLogs {
id Int @id @default(autoincrement())
dateTime DateTime? @default(now()) @db.Date
context String? @db.VarChar(100)
type String? @db.VarChar(100)
content Json? @db.JsonB
description String? @db.VarChar(500)
Instance Instance? @relation(fields: [instanceId], references: [id], onDelete: Cascade)
instanceId Int? @db.Integer
}

0 comments on commit a2474ed

Please sign in to comment.