Skip to content

Data Model & Storage

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

Primary store: Postgres (Neon) 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 Neon Postgres; 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 (Neon) and set ROOT_POSTGRES_URL (+ ROOT_POSTGRES_URL_NON_POOLING)
  2. Run migrations and seed
Terminal window
# If migrations are in repo
yarn prisma:generate
# Apply migrations with Prisma CLI

Notes:

  • Date ranges use tstzrange for availability queries on orders