45+ Tables

Database Schema

Clientra CRM uses MySQL/MariaDB with the database name invejrek_crmmain. All tables use utf8mb4 character set and utf8mb4_unicode_ci collation for full Unicode support.

ℹ Soft Deletes
Most entity tables (properties, leads, contacts, deals, owners) use soft deletes — records are marked with a deleted_at timestamp rather than being physically removed. Soft-deleted records are moved to the crm_trash table for recovery.

Core Tables

properties

The main property listings table. Each row represents a real estate property in the CRM.

ColumnTypeNullDefaultDescription
idINT UNSIGNEDNOPrimary key (auto-increment)
refVARCHAR(20)NOUnique reference number (e.g., PROP-001)
statusENUMNO'Available'Available / Reserved / Sold / Rented / Off Market
purposeENUMNO'Sale'Sale / Rent
typeVARCHAR(50)YESNULLApartment, Villa, Office, Townhouse, etc.
location_idINT UNSIGNEDYESNULLFK → locations.id
community_idINT UNSIGNEDYESNULLFK → communities.id
unit_numberVARCHAR(20)YESNULLUnit/flat number
bedroomsTINYINTYESNULLBedroom count (0 = Studio)
bathroomsTINYINTYESNULLBathroom count
size_sqftDECIMAL(10,2)YESNULLBuilt-up area in sq. ft.
plot_areaDECIMAL(10,2)YESNULLPlot area in sq. ft. (villas)
priceDECIMAL(15,2)YESNULLAsking price
owner_idINT UNSIGNEDYESNULLFK → owners.id
project_idINT UNSIGNEDYESNULLFK → real_estate_projects.id
cover_image_idINT UNSIGNEDYESNULLFK → documents.id (cover photo)
created_byINT UNSIGNEDYESNULLFK → users.id
created_atTIMESTAMPNOCURRENT_TIMESTAMPRecord creation time
updated_atTIMESTAMPYESNULLLast update time
deleted_atTIMESTAMPYESNULLSoft delete timestamp

leads

ColumnTypeNullDefaultDescription
idINT UNSIGNEDNOPrimary key
refVARCHAR(20)NOReference (e.g., LEAD-001)
nameVARCHAR(150)NOLead's full name
phoneVARCHAR(30)YESNULLPrimary phone number
emailVARCHAR(150)YESNULLEmail address
statusENUMNO'New'New / Contacted / Viewing / Offer / Won / Lost
sourceVARCHAR(50)YESNULLLead source (Website, Meta Ads, Referral, etc.)
campaignVARCHAR(100)YESNULLMarketing campaign name
priorityENUMNO'Normal'Low / Normal / High / Urgent
budget_minDECIMAL(15,2)YESNULLMinimum budget
budget_maxDECIMAL(15,2)YESNULLMaximum budget
property_typeVARCHAR(50)YESNULLPreferred property type
bedroomsVARCHAR(20)YESNULLPreferred bedroom count
location_idINT UNSIGNEDYESNULLPreferred location FK
assigned_toINT UNSIGNEDYESNULLFK → users.id (assigned agent)
followup_dateDATEYESNULLNext follow-up date
created_atTIMESTAMPNOCURRENT_TIMESTAMP
deleted_atTIMESTAMPYESNULLSoft delete timestamp

contacts

ColumnTypeDescription
idINT UNSIGNEDPrimary key
refVARCHAR(20)Reference number (e.g., CON-001)
nameVARCHAR(150)Full name
phoneVARCHAR(30)Primary phone
phone2VARCHAR(30)Secondary phone
emailVARCHAR(150)Email address
typeENUMAgent / Client / Developer / Other
statusENUMActive / Inactive / VIP
nationalityVARCHAR(80)Country of nationality
passport_numberVARCHAR(50)Passport number
emirates_idVARCHAR(20)UAE Emirates ID (UAE Edition)
dobDATEDate of birth
languageVARCHAR(30)Preferred language
created_atTIMESTAMPCreation timestamp
deleted_atTIMESTAMPSoft delete timestamp

deals

ColumnTypeDescription
idINT UNSIGNEDPrimary key
refVARCHAR(20)Reference (e.g., DEAL-001)
titleVARCHAR(200)Deal title/description
stageENUMnew / contacted / viewing / offer / negotiation / won / lost
valueDECIMAL(15,2)Deal value (sale/rent amount)
commission_amountDECIMAL(15,2)Expected commission
lead_idINT UNSIGNEDFK → leads.id (source lead)
property_idINT UNSIGNEDFK → properties.id
contact_idINT UNSIGNEDFK → contacts.id
assigned_toINT UNSIGNEDFK → users.id
created_atTIMESTAMPCreation timestamp
closed_atTIMESTAMPWhen deal was won/lost
deleted_atTIMESTAMPSoft delete timestamp

owners

ColumnTypeDescription
idINT UNSIGNEDPrimary key
OwnerRefVARCHAR(50)Reference (e.g., OWN-001)
NameVARCHAR(100)Owner full name
Name2VARCHAR(100)Secondary name (e.g., Arabic name)
PhoneVARCHAR(50)Primary phone number
Mobile2VARCHAR(50)Secondary phone number
EmailVARCHAR(100)Primary email address
Email2VARCHAR(100)Secondary email address
LocationVARCHAR(100)Location (from lookups)
CommunityVARCHAR(100)Community (from lookups, filtered by location)
UnitNumberVARCHAR(50)Unit number reference
ProjectNameVARCHAR(255)Linked project name
ProjectRefVARCHAR(50)Linked project reference
PriceDECIMAL(15,2)Property price
StatusVARCHAR(50)Owner status (Active, Inactive, Prospect, VIP, Blacklisted)
NotesTEXTOwner notes (preserves line breaks)
WhatsappSentTINYINT(1)WhatsApp status (0=Pending, 1=Sent)
created_atTIMESTAMPCreation timestamp
updated_atTIMESTAMPLast modification timestamp

units

⚠ Table Name: units (not real_estate_units)
The unit inventory table is named units. There is no real_estate_units table. The global search and all queries must reference units.
ColumnTypeDescription
idINT UNSIGNEDPrimary key
refVARCHAR(20)Unit reference number
project_idINT UNSIGNEDFK → real_estate_projects.id
unit_numberVARCHAR(20)Unit identifier (e.g., 1201)
typeVARCHAR(50)Apartment, Studio, Penthouse, etc.
bedroomsTINYINTBedroom count
bathroomsTINYINTBathroom count
size_sqftDECIMAL(10,2)Size in square feet
floorSMALLINTFloor number
viewVARCHAR(50)View type
priceDECIMAL(15,2)Unit price
statusENUMAvailable / Reserved / Sold / Rented
furnishedENUMFurnished / Unfurnished / Semi

Project Tables

real_estate_projects

ColumnTypeDescription
idINT UNSIGNEDPrimary key
refVARCHAR(20)Project reference
nameVARCHAR(200)Project name
developer_idINT UNSIGNEDFK → developers.id
location_idINT UNSIGNEDFK → locations.id
community_idINT UNSIGNEDFK → communities.id
total_unitsINTTotal unit count in project
available_unitsINTCurrently available units
starting_priceDECIMAL(15,2)Lowest unit price
handover_dateDATEProjected completion date
broker_commissionDECIMAL(5,2)Commission % for brokers
latitudeDECIMAL(10,7)GPS latitude
longitudeDECIMAL(10,7)GPS longitude
amenitiesJSONAmenity list as JSON array
layouts_dataJSONUnit type breakdown data

Lookup Tables

The following tables provide dynamic dropdown data throughout the application:

TableDescriptionKey Columns
developersReal estate developers/buildersid, name, country, website
locationsEmirates and areasid, name, emirate
communitiesSub-communities and buildingsid, name, location_id
project_namesLinked project name lookupid, name, developer_id
phasesProject phase identifiersid, name, project_id

Communication Tables

communications

The unified communications table stores all interaction records across all channels and entity types.

ColumnTypeDescription
idINT UNSIGNEDPrimary key
typeENUMemail / call / whatsapp / sms / meeting / note
statusENUMdraft / sent / delivered / read / failed / logged
entity_typeVARCHAR(30)Entity type: lead, deal, contact, property, owner
entity_idINT UNSIGNEDID of the linked entity
user_idINT UNSIGNEDFK → users.id (sender/logger)
contact_idINT UNSIGNEDFK → contacts.id (recipient)
subjectVARCHAR(255)Email subject or call summary
bodyTEXTMessage content (use body — NOT comment)
directionENUMinbound / outbound
durationSMALLINTCall duration in seconds
created_atTIMESTAMPRecord creation time
updated_atTIMESTAMPLast update time
ℹ Legacy Table: lead_communications
The old lead_communications table still exists during migration. All new code must use the unified communications table. The migration to a single table is in progress.

Other Communication Tables

TableDescription
email_accountsIMAP/SMTP account configurations (passwords encrypted with app_key)
email_account_permissionsPer-user access to email accounts
email_cacheCached email headers for performance
email_templatesReusable email templates
chat_messagesInternal team chat messages
notificationsIn-app notification records per user

Financial Tables

TableKey ColumnsDescription
contracts id, ref, type, status, deal_id, property_id, value, ejari_number, tawtheeq_number Contract records with UAE-specific regulatory fields
invoices id, ref, status, deal_id, contact_id, subtotal, vat_amount, total, due_date Financial invoices with VAT calculation
payments id, invoice_id, amount, payment_date, method, reference Payment records against invoices
commissions id, deal_id, agent_id, amount, agent_share, company_share, status, approved_at, paid_at Commission records with approval workflow

HR Tables

TableKey ColumnsDescription
hr_employeesid, user_id, employee_id, department_id, job_title, salary, join_date, statusEmployee records linked to CRM users
hr_attendanceid, employee_id, date, status (present/absent/leave/holiday), check_in, check_outDaily attendance records
hr_leavesid, employee_id, type (annual/sick/emergency), from_date, to_date, status, approved_byLeave requests and approvals
hr_payrollid, employee_id, month, year, basic_salary, allowances, deductions, net_salary, statusMonthly payroll records
departmentsid, name, head_user_id, descriptionDepartment structure (Listing, Sales, HR, etc.)
teamsid, name, department_id, team_lead_idTeams within departments
team_membersid, team_id, user_id, roleTeam membership records

System Tables

TableDescription
usersCRM user accounts (id, username, email, full_name, role, password_hash, active, created_at)
app_settingsKey-value store for application settings (key, value, updated_at)
crm_featuresFeature flag toggles (feature_key, enabled, edition)
crm_modulesModule registry for navigation and routing
crm_trashSoft-deleted records staging (entity_type, entity_id, data JSON, deleted_at, deleted_by)
crm_audit_changesField-level change tracking (entity_type, entity_id, field, old_value, new_value, changed_by, changed_at)
activity_logHigh-level activity log (user_id, action, entity_type, entity_id, description, ip_address, created_at)
tasksTask records (id, title, status, priority, event_type, entity_type, entity_id, assigned_to, due_at)
documentsFile attachment records (id, entity_type, entity_id, filename, original_name, mime_type, size, storage_path)
pdf_templatesPDF document template definitions
pdf_letterheadsCompany letterhead configurations
pdf_documentsGenerated PDF document records

RBAC Tables

The Role-Based Access Control system uses multiple tables to provide granular permission management at both role and user levels.

TableDescription
role_permissionsPermissions granted to each role (role, module, action, allowed)
user_permissionsPer-user permission overrides that supersede role-based permissions
user_feature_overridesPer-user feature flag overrides
user_module_visibilityControls which sidebar modules a user can see
entity_responsibilitiesPrimary/secondary agent assignment per entity

Addon Tables

TableDescription
addonsInstalled addon registry (slug, name, version, enabled, installed_at)
meta_accountsMeta (Facebook) ad account configurations
meta_form_mappingsField mappings from Meta lead forms to CRM lead fields
meta_lead_queueIncoming leads from Meta webhook pending processing
meta_settingsMeta integration global settings
meta_webhook_logsRaw webhook event logs from Meta
cold_call_importsCold call list import batches
cold_call_recordsIndividual cold call contact records with assignment and status
aw_api_keysAPI key authentication records
aw_api_logsAPI request access logs
aw_oauth_clientsOAuth 2.0 client registrations
aw_rate_limitsRate limiting tracking per API key/IP
aw_webhooksOutbound webhook subscriptions
automation_rulesAutomation rule definitions (trigger, conditions, actions JSON)
automation_logAutomation rule execution history