prisma/schema.prisma. Current schema có 69 models.
Cách đọc field contract
Tenant và authorization
Tòa nhà, tài khoản đăng nhập, hồ sơ nhân sự và grouped RBAC.Sơ đồ quan hệ thực thể (ERD)
Organizations — organizations
Organizations — organizations
- Database table:
organizationsKhông có model-level constraint ngoài field attributes trong Prisma schema.
Towers — towers
Towers — towers
- Database table:
towers @@unique([id, organization_id])@@unique([tower_code, organization_id])@@index([organization_id])
AuthUsers — auth_users
AuthUsers — auth_users
- Database table:
auth_users @@index([organization_id])
Users — users
Users — users
- Database table:
users @@unique([id, organization_id])@@index([organization_id])@@index([tower_id])
UserBuildings — user_buildings
UserBuildings — user_buildings
- Database table:
user_buildings @@id([user_id, tower_id])@@index([organization_id])@@index([tower_id])
PermissionGroups — permission_groups
PermissionGroups — permission_groups
- Database table:
permission_groups @@unique([id, organization_id])@@index([organization_id])
Permissions — permissions
Permissions — permissions
- Database table:
permissionsKhông có model-level constraint ngoài field attributes trong Prisma schema.
UserPermissionGroups — user_permission_groups
UserPermissionGroups — user_permission_groups
- Database table:
user_permission_groups @@id([user_id, permission_group_id])@@index([organization_id])@@index([permission_group_id])
PermissionGroupPermissions — permission_group_permissions
PermissionGroupPermissions — permission_group_permissions
- Database table:
permission_group_permissions @@id([permission_group_id, permission_id])@@index([permission_id])
OrganizationAuditLogs — organization_audit_logs
OrganizationAuditLogs — organization_audit_logs
- Database table:
organization_audit_logs @@index([organization_id, created_at])@@index([actor_account_id, created_at])
OrganizationOnboardingRequests — organization_onboarding_requests
OrganizationOnboardingRequests — organization_onboarding_requests
- Database table:
organization_onboarding_requests @@index([organization_id])@@index([actor_account_id])
Căn hộ, cư dân và phương tiện
Căn hộ, hồ sơ cư dân, membership, reconciliation import và phương tiện.Sơ đồ quan hệ thực thể (ERD)
Apartments — apartments
Apartments — apartments
- Database table:
apartments @@unique([id, tower_id])@@unique([tower_id, code])@@index([tower_id])
Residents — residents
Residents — residents
- Database table:
residents @@unique([id, tower_id])@@index([tower_id])@@index([tower_id, apartment])
ResidentApartmentMemberships — resident_apartment_memberships
ResidentApartmentMemberships — resident_apartment_memberships
- Database table:
resident_apartment_memberships @@unique([resident_id, apartment_id])@@index([tower_id, apartment_id])@@index([tower_id, resident_id])
ResidentImportReconciliationItems — resident_import_reconciliation_items
ResidentImportReconciliationItems — resident_import_reconciliation_items
- Database table:
resident_import_reconciliation_items @@unique([import_id, row_number])@@index([tower_id, status, id])@@index([tower_id, apartment_candidate_id])@@index([tower_id, selected_existing_resident_id])
ResidentMiniappLinks — resident_miniapp_links
ResidentMiniappLinks — resident_miniapp_links
- Database table:
resident_miniapp_links @@unique([zalo_user_id, apartment_id])@@index([tower_id, status, created_at])@@index([resident_id])
Vehicles — vehicles
Vehicles — vehicles
- Database table:
vehicles @@unique([id, tower_id])@@index([tower_id])@@index([tower_id, apartment_id, status])@@index([tower_id, service_id])
VehicleCards — vehicle_cards
VehicleCards — vehicle_cards
- Database table:
vehicle_cards @@index([tower_id])
Dịch vụ và cấu hình thu phí
Dịch vụ, assignment, chỉ số, đối tác, danh mục thu và khóa kỳ.Services — services
Services — services
- Database table:
services @@unique([id, tower_id])@@index([tower_id])
ServiceApartments — service_apartments
ServiceApartments — service_apartments
- Database table:
service_apartments @@index([tower_id])@@index([tower_id, vehicle_id])
Partners — partners
Partners — partners
- Database table:
partners @@index([tower_id])
MeterReadings — meter_readings
MeterReadings — meter_readings
- Database table:
meter_readings @@index([tower_id])@@index([tower_id, period])
ReceiptCategories — receipt_categories
ReceiptCategories — receipt_categories
- Database table:
receipt_categories @@index([tower_id])
PaymentCodes — payment_codes
PaymentCodes — payment_codes
- Database table:
payment_codes @@index([tower_id])
CycleLocks — cycle_locks
CycleLocks — cycle_locks
- Database table:
cycle_locks @@index([tower_id])
Công nợ, thu chi và sổ quỹ
Bảng kê, điều chỉnh, phiếu thu, phân bổ, tiền thừa, giao dịch và audit.Sơ đồ quan hệ thực thể (ERD)
Bills — bills
Bills — bills
- Database table:
bills @@unique([id, tower_id])@@index([tower_id])@@index([tower_id, cycle])@@index([tower_id, apartment])@@index([tower_id, apartment, cycle(sort: Desc), id(sort: Desc)], map: "bills_portal_order_idx")@@index([tower_id, created_at(sort: Desc), id(sort: Desc)], map: "bills_review_order_idx")
BillLines — bill_lines
BillLines — bill_lines
- Database table:
bill_lines @@unique([id, tower_id])@@unique([id, bill_id, tower_id])@@index([tower_id, bill_id])@@index([bill_id, line_no])@@index([tower_id])
BillingAdjustments — billing_adjustments
BillingAdjustments — billing_adjustments
- Database table:
billing_adjustments @@unique([id, tower_id])@@unique([tower_id, adjustment_code])@@index([tower_id, source_bill_id])@@index([tower_id, status])
BillingAdjustmentLines — billing_adjustment_lines
BillingAdjustmentLines — billing_adjustment_lines
- Database table:
billing_adjustment_lines @@index([tower_id, adjustment_id])@@index([tower_id, source_bill_id])@@index([tower_id, source_bill_line_id])
Receipts — receipts
Receipts — receipts
- Database table:
receipts @@unique([id, tower_id])@@index([tower_id])@@index([tower_id, accounting_date])@@index([tower_id, apartment, accounting_date(sort: Desc), id(sort: Desc)], map: "receipts_portal_order_idx")
ReceiptAllocations — receipt_allocations
ReceiptAllocations — receipt_allocations
- Database table:
receipt_allocations @@index([tower_id, receipt_id])@@index([tower_id, adjustment_id])@@index([tower_id])@@index([tower_id, bill_id])@@index([tower_id, bill_line_id])
ExcessPaymentLedger — excess_payment_ledger
ExcessPaymentLedger — excess_payment_ledger
- Database table:
excess_payment_ledger @@index([tower_id, apartment])@@index([tower_id])@@index([tower_id, adjustment_id])
Debits — debits
Debits — debits
- Database table:
debits @@index([tower_id])
ExcessPayments — excess_payments
ExcessPayments — excess_payments
- Database table:
excess_payments @@index([tower_id])
AccountingTransactions — accounting_transactions
AccountingTransactions — accounting_transactions
- Database table:
accounting_transactions @@index([tower_id])
Cashbook — cashbook
Cashbook — cashbook
- Database table:
cashbook @@index([tower_id])@@index([tower_id, receipt_id])@@index([tower_id, date])
Bankbook — bankbook
Bankbook — bankbook
- Database table:
bankbook @@index([tower_id])@@index([tower_id, receipt_id])@@index([tower_id, date])
AuditLogs — audit_logs
AuditLogs — audit_logs
- Database table:
audit_logs @@index([tower_id, period])@@index([tower_id])
Tương tác cư dân
Phản ánh, yêu cầu dịch vụ, nội dung, biểu mẫu, sửa chữa và đánh giá.Feedback — feedback
Feedback — feedback
- Database table:
feedback @@index([tower_id])@@index([tower_id, miniapp_zalo_user_id])@@index([tower_id, miniapp_zalo_user_id, apartment, created_at(sort: Desc), id(sort: Desc)], map: "feedback_portal_order_idx")
Posts — posts
Posts — posts
- Database table:
posts @@index([tower_id])
Polls — polls
Polls — polls
- Database table:
polls @@index([tower_id])
Comments — comments
Comments — comments
ServiceRequests — service_requests
ServiceRequests — service_requests
- Database table:
service_requests @@index([tower_id])@@index([tower_id, miniapp_zalo_user_id])@@index([tower_id, miniapp_zalo_user_id, apartment, created_at(sort: Desc), id(sort: Desc)], map: "service_requests_portal_order_idx")
RequestComments — request_comments
RequestComments — request_comments
- Database table:
request_comments @@index([tower_id, subject_type, subject_id])@@index([tower_id])
RequestAttachments — request_attachments
RequestAttachments — request_attachments
- Database table:
request_attachments @@index([tower_id, subject_type, subject_id])@@index([tower_id])
RequestTasks — request_tasks
RequestTasks — request_tasks
- Database table:
request_tasks @@index([tower_id, subject_type, subject_id])@@index([tower_id])
FeedbackForms — feedback_forms
FeedbackForms — feedback_forms
- Database table:
feedback_forms @@index([tower_id])
Repairs — repairs
Repairs — repairs
- Database table:
repairs @@index([tower_id])
InteractionReports — interaction_reports
InteractionReports — interaction_reports
- Database table:
interaction_reports @@index([tower_id])
AppRatings — app_ratings
AppRatings — app_ratings
- Database table:
app_ratings @@index([tower_id])
ServiceRatings — service_ratings
ServiceRatings — service_ratings
- Database table:
service_ratings @@index([tower_id])
Nhắc công nợ và email
Campaign, notification job, provider event và suppression.Sơ đồ quan hệ thực thể (ERD)
BillingReminderCampaigns — billing_reminder_campaigns
BillingReminderCampaigns — billing_reminder_campaigns
- Database table:
billing_reminder_campaigns @@unique([tower_id, request_id])@@unique([id, tower_id])@@index([tower_id, created_at])
Notifications — notifications
Notifications — notifications
- Database table:
notifications @@index([tower_id])@@index([tower_id, status, next_attempt_at])@@index([channel, status, next_attempt_at])@@index([resident_id])@@index([campaign_id, tower_id])@@index([resident_id, tower_id])@@index([provider_message_id])
NotificationEvents — notification_events
NotificationEvents — notification_events
- Database table:
notification_events @@index([tower_id, provider_message_id])
EmailSuppressions — email_suppressions
EmailSuppressions — email_suppressions
- Database table:
email_suppressions @@unique([tower_id, email])@@index([tower_id])
Import
Preview, commit state và lỗi theo dòng của file import.Sơ đồ quan hệ thực thể (ERD)
ImportHistory — import_history
ImportHistory — import_history
- Database table:
import_history @@unique([id, tower_id])@@index([tower_id])
ImportErrors — import_errors
ImportErrors — import_errors
- Database table:
import_errors @@index([tower_id, import_id])@@index([tower_id])
Cấu hình, nội dung và landing
Danh mục cấu hình còn lại, handbook, địa điểm và contact công khai.Buildings — buildings
Buildings — buildings
- Database table:
buildingsKhông có model-level constraint ngoài field attributes trong Prisma schema.
Handbook — handbook
Handbook — handbook
- Database table:
handbook @@index([tower_id])
BuildingPlaces — building_places
BuildingPlaces — building_places
- Database table:
building_places @@index([tower_id])
AccountingAccounts — accounting_accounts
AccountingAccounts — accounting_accounts
- Database table:
accounting_accounts @@index([tower_id])
ReceiptForms — receipt_forms
ReceiptForms — receipt_forms
- Database table:
receipt_forms @@index([tower_id])
Configs — configs
Configs — configs
- Database table:
configs @@index([tower_id])
LandingContacts — landing_contacts
LandingContacts — landing_contacts
- Database table:
landing_contacts @@index([status, created_at])@@index([email])@@index([retention_until])
AI knowledge và chat
Tài liệu tri thức, đoạn nội dung, cuộc hội thoại, tin nhắn và giới hạn truy cập AI trong schema.Sơ đồ quan hệ thực thể (ERD)
AiKnowledgeDocuments — ai_knowledge_documents
AiKnowledgeDocuments — ai_knowledge_documents
- Database table:
ai_knowledge_documents @@unique([id, tower_id])@@unique([tower_id, content_hash])@@index([tower_id, status, created_at])
AiKnowledgeChunks — ai_knowledge_chunks
AiKnowledgeChunks — ai_knowledge_chunks
- Database table:
ai_knowledge_chunks @@unique([document_id, chunk_index])@@index([tower_id, document_id])
AiChatThreads — ai_chat_threads
AiChatThreads — ai_chat_threads
- Database table:
ai_chat_threads @@unique([id, tower_id])@@index([tower_id, created_by, updated_at])
AiChatMessages — ai_chat_messages
AiChatMessages — ai_chat_messages
- Database table:
ai_chat_messages @@index([thread_id, created_at])@@index([tower_id, created_at])
AiRateLimits — ai_rate_limits
AiRateLimits — ai_rate_limits
- Database table:
ai_rate_limits @@id([tower_id, actor, scope, window_start])@@index([window_start])
idInt@id @default(autoincrement())tower_idString@db.VarChar(64)post_titleString@default("")contentString@default("")authorString@default("")created_atDateTime@default(now()) @db.Timestamptz(3)tower_recordTowers@relation(fields: [tower_id], references: [tower_code], onDelete: Restrict, onUpdate: Cascade)comments@@index([tower_id])