npm run setup is a shortcut. This page does the same steps by hand, so you can change any of them.
1. Database client
npx prisma generate
Reads prisma/schema.prisma and writes the typed client into node_modules/@prisma/client. Run it again after every change to the schema.
2. Tables
npx prisma db push
Creates (or updates) the tables in the database named by DATABASE_URL. With the default SQLite setting that is the file prisma/dar.db. Existing data is kept; Prisma stops and asks before any change that would lose data.
3. First data
node prisma/seed.mjs
The seed fills only empty tables:
| Table empty? | The seed adds |
|---|---|
| Setting | the agency name, contact details and currency (OMR, 3 decimals) |
| Area | the 8 sample areas, with "picture life here" text and nearby places |
| StaffUser | the owner from OWNER_EMAIL / OWNER_PASSWORD, then 4 sample staff |
| Property | 24 sample listings and their photos |
| Lead | 15 inquiries and 9 viewings |
Starting without the sample listings
For a real agency you usually want the settings, the areas and the owner, but not the sample listings, staff or inquiries. Edit prisma/sample-data.mjs before the first seed: empty the agents, properties and leads arrays and change agency and areas to your own. Then run the seed. The sample photos in public/images can be deleted.
4. Build and start
npm run build
npm start # listens on port 3303
npm start runs next start -p 3303. Change the port in package.json if needed.
Choosing the database
SQLite is enough for one agency with a few staff members: the whole agency is one file you can copy. Use PostgreSQL when you run several server instances or want a managed database:
- In
prisma/schema.prisma, changeprovider = "sqlite"toprovider = "postgresql". - Set
DATABASE_URL="postgresql://user:password@host:5432/dar". - Run steps 1 to 3 again.
Nothing else changes: prices are integers and text search uses contains, which both databases support.
Uploaded photos
Photos uploaded in the dashboard are saved in UPLOAD_DIR (default storage/uploads) and served by the app at /uploads/<file>. They are outside public/ on purpose: Next.js only serves files that existed in public/ at build time. Back this folder up with the database. Next: Deployment.