Data Model
The Postgres tables behind companies, items, customers and reservations
The schema is defined in src/db/schema.ts (application tables) and src/db/auth-schema.ts
(generated by Better Auth). Twenty-two tables in total. Every application table that belongs to a company has a
company_id column that references the Better Auth organization table.
Accounts and companies
| Table | Purpose |
|---|---|
user, session, account, verification | Better Auth: people, their sessions and credentials |
organization | A company. Its slug is the /[company] URL segment |
member | A user's role in a company: owner, admin, manager, employee, viewer or customer |
invitation | Pending staff invitations, valid for 7 days |
user_preference | Per-user notification and display preferences |
company_profile | Tagline, description, contact details, currency, locale, time zone, plan and trial end |
Rental data
| Table | Purpose |
|---|---|
category, item | The catalog: price, price unit, stock quantity, status and whether the item is public |
item_stage, item_unit_stage | The company's post-return steps, and how many units of each item currently wait in each step |
customer | A renter. Optionally linked to a login through user_id |
reservation, reservation_item | A booking with a period and status, and its lines with quantity and the price at booking time |
content, comment | Pages and news with block bodies, and staff comments on them |
attendance | Staff check-in and check-out events |
custom_field | Definitions of extra fields for items, customers and reservations |
table_permission | Per-member overrides of what a role may do on a resource |
audit_log | Who changed what, and when |
Conventions
- Custom values are stored in a
customJSONB column on items, customers and reservations, keyed by the field's key. - Prices are
numeric(10,2)and copied onto each reservation line, so later price edits never change past bookings. - Times are stored as timestamps without a zone and treated as UTC.
- Slugs (items, pages, news, categories) are unique within a company, not globally.