feat: backend API NestJS + Prisma + JWT auth + todos los módulos
This commit is contained in:
@@ -0,0 +1,236 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
}
|
||||
|
||||
model chats {
|
||||
id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
|
||||
user_id String @db.Uuid
|
||||
professional_id String @db.Uuid
|
||||
created_at DateTime @default(now()) @db.Timestamptz(6)
|
||||
users_chats_professional_idTousers users @relation("chats_professional_idTousers", fields: [professional_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||
users_chats_user_idTousers users @relation("chats_user_idTousers", fields: [user_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||
messages messages[]
|
||||
|
||||
@@unique([user_id, professional_id])
|
||||
@@index([professional_id], map: "idx_chats_professional_id")
|
||||
@@index([user_id], map: "idx_chats_user_id")
|
||||
}
|
||||
|
||||
model cities {
|
||||
id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
|
||||
region_id String @db.Uuid
|
||||
name String @db.VarChar(255)
|
||||
latitude Decimal? @db.Decimal(10, 7)
|
||||
longitude Decimal? @db.Decimal(10, 7)
|
||||
regions regions @relation(fields: [region_id], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
|
||||
@@index([region_id], map: "idx_cities_region_id")
|
||||
}
|
||||
|
||||
/// This table contains check constraints and requires additional setup for migrations. Visit https://pris.ly/d/check-constraints for more info.
|
||||
model comments {
|
||||
id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
|
||||
author_id String @db.Uuid
|
||||
destination_id String @db.Uuid
|
||||
service_id String? @db.Uuid
|
||||
content String?
|
||||
score Int @db.SmallInt
|
||||
is_from_user Boolean @default(true)
|
||||
created_at DateTime @default(now()) @db.Timestamptz(6)
|
||||
users_comments_author_idTousers users @relation("comments_author_idTousers", fields: [author_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||
users_comments_destination_idTousers users @relation("comments_destination_idTousers", fields: [destination_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||
services services? @relation(fields: [service_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||
|
||||
@@index([author_id], map: "idx_comments_author_id")
|
||||
@@index([destination_id], map: "idx_comments_destination_id")
|
||||
@@index([service_id], map: "idx_comments_service_id")
|
||||
}
|
||||
|
||||
model countries {
|
||||
id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
|
||||
name String @unique @db.VarChar(255)
|
||||
regions regions[]
|
||||
}
|
||||
|
||||
model messages {
|
||||
id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
|
||||
chat_id String @db.Uuid
|
||||
sender_id String @db.Uuid
|
||||
content String
|
||||
created_at DateTime @default(now()) @db.Timestamptz(6)
|
||||
chats chats @relation(fields: [chat_id], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
users users @relation(fields: [sender_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||
|
||||
@@index([chat_id], map: "idx_messages_chat_id")
|
||||
@@index([created_at], map: "idx_messages_created_at")
|
||||
}
|
||||
|
||||
model payment_methods {
|
||||
id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
|
||||
professional_id String @unique @db.Uuid
|
||||
nequi Boolean? @default(false)
|
||||
datafono Boolean? @default(false)
|
||||
transferencia Boolean? @default(false)
|
||||
professionals professionals @relation(fields: [professional_id], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
}
|
||||
|
||||
model professionals {
|
||||
id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
|
||||
user_id String @unique @db.Uuid
|
||||
identification String? @db.VarChar(50)
|
||||
address String?
|
||||
additional_address String?
|
||||
profession String? @db.VarChar(255)
|
||||
rate Decimal? @db.Decimal(10, 2)
|
||||
rate_preferences String?
|
||||
location_preferences String? @default("office") @db.VarChar(20)
|
||||
banner_picture String?
|
||||
identification_picture String?
|
||||
certificate_picture String?
|
||||
latitude Decimal? @db.Decimal(10, 7)
|
||||
longitude Decimal? @db.Decimal(10, 7)
|
||||
average_score Decimal? @default(0) @db.Decimal(3, 2)
|
||||
is_active Boolean? @default(true)
|
||||
created_at DateTime @default(now()) @db.Timestamptz(6)
|
||||
updated_at DateTime @default(now()) @db.Timestamptz(6)
|
||||
payment_methods payment_methods?
|
||||
users users @relation(fields: [user_id], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
schedules schedules[]
|
||||
services services[]
|
||||
specializations specializations[]
|
||||
|
||||
@@index([user_id], map: "idx_professionals_user_id")
|
||||
}
|
||||
|
||||
model professions {
|
||||
id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
|
||||
name String @unique @db.VarChar(255)
|
||||
}
|
||||
|
||||
model regions {
|
||||
id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
|
||||
country_id String @db.Uuid
|
||||
name String @db.VarChar(255)
|
||||
cities cities[]
|
||||
countries countries @relation(fields: [country_id], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
|
||||
@@index([country_id], map: "idx_regions_country_id")
|
||||
}
|
||||
|
||||
model reputations {
|
||||
user_id String @id @db.Uuid
|
||||
total Int @default(0)
|
||||
average Decimal @default(0) @db.Decimal(3, 2)
|
||||
total_pro Int @default(0)
|
||||
average_pro Decimal @default(0) @db.Decimal(3, 2)
|
||||
updated_at DateTime @default(now()) @db.Timestamptz(6)
|
||||
users users @relation(fields: [user_id], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
}
|
||||
|
||||
/// This table contains check constraints and requires additional setup for migrations. Visit https://pris.ly/d/check-constraints for more info.
|
||||
model schedules {
|
||||
id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
|
||||
professional_id String @db.Uuid
|
||||
day_of_week Int @db.SmallInt
|
||||
enabled Boolean? @default(false)
|
||||
continuous_day Boolean? @default(false)
|
||||
range1_hour1 DateTime? @db.Time(6)
|
||||
range1_hour2 DateTime? @db.Time(6)
|
||||
range2_hour1 DateTime? @db.Time(6)
|
||||
range2_hour2 DateTime? @db.Time(6)
|
||||
professionals professionals @relation(fields: [professional_id], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
|
||||
@@unique([professional_id, day_of_week])
|
||||
@@index([professional_id], map: "idx_schedules_professional_id")
|
||||
}
|
||||
|
||||
model services {
|
||||
id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
|
||||
professional_id String @db.Uuid
|
||||
user_id String @db.Uuid
|
||||
address String?
|
||||
additional_address String?
|
||||
latitude Decimal? @db.Decimal(10, 7)
|
||||
longitude Decimal? @db.Decimal(10, 7)
|
||||
day DateTime @db.Date
|
||||
description String?
|
||||
rate Decimal? @db.Decimal(10, 2)
|
||||
range1_hour1 DateTime? @db.Time(6)
|
||||
range1_hour2 DateTime? @db.Time(6)
|
||||
status service_status @default(pending)
|
||||
location_preference service_location? @default(office)
|
||||
professional_scored Boolean? @default(false)
|
||||
user_scored Boolean? @default(false)
|
||||
created_at DateTime @default(now()) @db.Timestamptz(6)
|
||||
updated_at DateTime @default(now()) @db.Timestamptz(6)
|
||||
comments comments[]
|
||||
professionals professionals @relation(fields: [professional_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||
users users @relation(fields: [user_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||
|
||||
@@index([day], map: "idx_services_day")
|
||||
@@index([professional_id], map: "idx_services_professional_id")
|
||||
@@index([status], map: "idx_services_status")
|
||||
@@index([user_id], map: "idx_services_user_id")
|
||||
}
|
||||
|
||||
model settings {
|
||||
key String @id @db.VarChar(100)
|
||||
value Json
|
||||
updated_at DateTime @default(now()) @db.Timestamptz(6)
|
||||
}
|
||||
|
||||
model specializations {
|
||||
id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
|
||||
professional_id String @db.Uuid
|
||||
name String @db.VarChar(255)
|
||||
picture String?
|
||||
professionals professionals @relation(fields: [professional_id], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
|
||||
@@index([professional_id], map: "idx_specializations_professional_id")
|
||||
}
|
||||
|
||||
model users {
|
||||
id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
|
||||
email String? @unique @db.VarChar(255)
|
||||
phone String? @unique @db.VarChar(20)
|
||||
password_hash String? @db.VarChar(255)
|
||||
name String @db.VarChar(255)
|
||||
nickname String? @db.VarChar(100)
|
||||
city String? @db.VarChar(100)
|
||||
picture String?
|
||||
birthday DateTime? @db.Date
|
||||
gender String? @db.VarChar(20)
|
||||
pro_state Int @default(0) @db.SmallInt
|
||||
fcm_token String?
|
||||
is_phone_verified Boolean? @default(false)
|
||||
is_email_verified Boolean? @default(false)
|
||||
created_at DateTime @default(now()) @db.Timestamptz(6)
|
||||
updated_at DateTime @default(now()) @db.Timestamptz(6)
|
||||
chats_chats_professional_idTousers chats[] @relation("chats_professional_idTousers")
|
||||
chats_chats_user_idTousers chats[] @relation("chats_user_idTousers")
|
||||
comments_comments_author_idTousers comments[] @relation("comments_author_idTousers")
|
||||
comments_comments_destination_idTousers comments[] @relation("comments_destination_idTousers")
|
||||
messages messages[]
|
||||
professionals professionals?
|
||||
reputations reputations?
|
||||
services services[]
|
||||
}
|
||||
|
||||
enum service_location {
|
||||
office
|
||||
delivery
|
||||
}
|
||||
|
||||
enum service_status {
|
||||
pending
|
||||
accepted
|
||||
denied
|
||||
active
|
||||
cancelled
|
||||
completed
|
||||
self_booked
|
||||
}
|
||||
Reference in New Issue
Block a user