Setting (1 row)
Area 1───* Property *───1 StaffUser (agent)
│ 1
├──* PropertyImage
├──* Lead *───1 StaffUser (agent)
│ ├──* LeadNote
│ └──* Viewing
└──* Viewing *───1 StaffUser (agent)
Setting
One row (id = 1) edited in Dashboard > Settings: names and taglines in both languages, phone, WhatsApp, email, address, office hours, licence number, currency (ISO code) and currencyDecimals.
Area
slug, nameAr, nameEn, governorate (one of the 11 governorates in src/lib/oman.ts), descAr/descEn, lifeAr/lifeEn ("picture life here"), places (JSON array of {kind, nameAr, nameEn, minutes}; kinds in PLACE_KINDS), image, sort, active. An inactive area hides its listings from the website.
StaffUser
slug, name, nameAr, email (unique), passwordHash (scrypt), role (OWNER, ADMIN, AGENT), active, showOnSite, job titles and bios in both languages, phone, whatsapp, photo, languages (comma list of codes).
Property
| Column | Type | Notes |
|---|---|---|
slug, ref |
string, unique | ref like DAR-1025 |
titleAr/En, descAr/En |
string | |
purpose |
SALE / RENT |
|
type |
VILLA / APARTMENT / TOWNHOUSE / LAND / OFFICE |
|
status |
DRAFT / PUBLISHED / UNDER_OFFER / SOLD / RENTED |
|
price |
integer | minor units; rent per month |
bedrooms, bathrooms, areaM2, plotM2, yearBuilt |
integer | |
furnished |
UNFURNISHED / SEMI / FURNISHED |
|
amenities |
JSON string | array of keys from AMENITIES |
addressAr/En, areaId, agentId |
agent is nullable | |
featured, publishedAt, createdAt, updatedAt |
Indexes on (status, purpose, type), areaId, agentId.
PropertyImage
propertyId, url (/images/..., /uploads/... or https://...), virtual (made in the staging studio), sort (0 is the cover). Deleted with the listing.
Lead
An inquiry: code (unique, IQ- or VW-), kind (INQUIRY / VIEWING), propertyId?, agentId?, name, phone, email, message, status (NEW / CONTACTED / QUALIFIED / WON / LOST), locale. Keeps its history when the listing is deleted.
LeadNote
leadId, author (staff name), body, createdAt. Status and assignment changes are written here automatically.
Viewing
leadId?, propertyId, agentId?, name, phone, date (YYYY-MM-DD), time (HH:MM) in the agency's time zone, status (REQUESTED / CONFIRMED / DONE / NO_SHOW / CANCELLED), note.
Why strings for enums and JSON
SQLite has no enum or JSON column types in Prisma. Allowed values are checked by zod in src/lib/* and listed in src/lib/rules.ts; with PostgreSQL you may turn them into enums without changing the API.