Skip to content

Data Model & Storage

There is still an ongoing migration from FaunaDB to Superbase. Until now, FaunaDB is the main database.

Primary store: Postgres (Supabase) with Prisma

  • Schema: prisma/schema.prisma
  • Prisma client provided by @power-rent/prisma-client and consumed directly in services
  • Prisma client is always backed by Supabase; no stub implementation is used.

Legacy store: FaunaDB

  • Access via FaunaDB helpers and fql in server resolvers/context
  • Migration flags allow entity-by-entity cutover

Access patterns:

  • Tenant-aware services instantiated via createTenantServices (services/index.ts) after auth middleware
  • Dataloaders: server/graphql/helpers/dataloaderPostgres.js and server/graphql/helpers/dataloader.js

Initialization steps:

  1. Provision Postgres (Supabase) and set SUPABASE_PRISMA_URL (+ non-pooling)
  2. Run migrations and seed
Terminal window
# If migrations are in repo
yarn prisma:generate
# Apply migrations with Prisma CLI or Supabase migration process

Notes:

  • Row Level Security is expected on some tables per comments in schema; ensure policies in Supabase
  • Date ranges use tstzrange for availability queries on orders