Title: docs: write docs/architecture/data-model.md — PostgreSQL schema, entity relationships, and multi-tenant Hasura data layer
Issue Summary
docs/architecture/data-model.md must document the full PostgreSQL schema for both tenants (safetrust and hotel_industry), the entity relationships, and how Hasura exposes them as GraphQL. Content must be derived from reading the actual migration files — not invented or copied from OfferHub.
Type of Issue
Branch strategy
✅ docs/issue-N-data-model → consolidation-pattern
Expected Content
The contributor must read these files before writing:
ls infra/backend/migrations/safetrust/
ls infra/backend/migrations/hotel_industry/
cat infra/backend/migrations/safetrust/1731908676359_create_users/up.sql
cat infra/backend/migrations/safetrust/1786000000000_create_user_roles/up.sql
cat infra/backend/migrations/safetrust/1771690624593_create_escrows_table/up.sql
cat infra/backend/migrations/hotel_industry/1745664202191_create_reservations/up.sql
The document must cover:
1. safetrust schema tables — users, user_wallets, user_roles, roles, apartments, escrows, trustless_work_escrows, escrow_milestones, bid_requests, bid_status_histories
2. hotel_industry schema tables — hotels, rooms, room_types, reservations, escrow_transactions, escrow_transaction_users, room_images, pricing_rules
3. Entity relationship diagram — ASCII or Mermaid showing FK relationships
4. Role system — roles table (guest=1, host=2, admin=3), user_roles join table, how resolveHighestRole works in middleware
5. Wallet model — user_wallets with provider column (freighter vs pollar), chain_type, is_primary
6. Escrow state in DB — how trustless_work_escrows.status mirrors on-chain state
Files to create
| File |
Content |
docs/architecture/data-model.md |
Full schema doc ~200 lines |
Make sure to follow the Git Guidelines for Atomic Commits and read Contributing Guide
Title:
docs: write docs/architecture/data-model.md — PostgreSQL schema, entity relationships, and multi-tenant Hasura data layerIssue Summary
docs/architecture/data-model.mdmust document the full PostgreSQL schema for both tenants (safetrustandhotel_industry), the entity relationships, and how Hasura exposes them as GraphQL. Content must be derived from reading the actual migration files — not invented or copied from OfferHub.Type of Issue
Branch strategy
Expected Content
The contributor must read these files before writing:
The document must cover:
1.
safetrustschema tables —users,user_wallets,user_roles,roles,apartments,escrows,trustless_work_escrows,escrow_milestones,bid_requests,bid_status_histories2.
hotel_industryschema tables —hotels,rooms,room_types,reservations,escrow_transactions,escrow_transaction_users,room_images,pricing_rules3. Entity relationship diagram — ASCII or Mermaid showing FK relationships
4. Role system —
rolestable (guest=1, host=2, admin=3),user_rolesjoin table, howresolveHighestRoleworks in middleware5. Wallet model —
user_walletswithprovidercolumn (freighter vs pollar),chain_type,is_primary6. Escrow state in DB — how
trustless_work_escrows.statusmirrors on-chain stateFiles to create
docs/architecture/data-model.mdMake sure to follow the Git Guidelines for Atomic Commits and read Contributing Guide