Being Human — Internal Docs

Database

Drizzle, PGlite, and the migrations workflow

Tables

TablePurpose
wishlist_signupsLanding-page wishlist (email unique, source, referrer)
invites / invite_redemptionsInvitations
user_achievementsCanonical achievement unlocks
user, session, account, verificationbetter-auth core tables — shape is dictated by better-auth's drizzle adapter, don't restructure casually

All defined in apps/api/src/db/schema.ts.

Changing the schema

# 1. Edit apps/api/src/db/schema.ts
# 2. Generate the SQL migration
pnpm --filter api db:generate
# 3. Commit the new file in apps/api/drizzle/

Migrations apply automatically the next time the server boots (dev, test, and prod all run the same migrator). There is no separate "migrate" deploy step.

Local data

The embedded database lives in apps/api/.data/pglite (gitignored). Nuke the folder for a fresh start:

rm -rf apps/api/.data

Gotchas

  • PGlite doesn't create parent directoriescreateDb does mkdir -p first. Keep that if you touch it.
  • The account.accountId column doubles as the steamId64 for accounts with providerId = "steam" — achievement mirroring depends on this.
  • Postgres unique-violation code 23505 is used to detect double-redemption of invites; drizzle wraps errors, so the check walks error.cause.

On this page