Drizzle ORM schemas, relations, and migrations for Esposter's PostgreSQL database. The source of truth for all relational data — usable in both browser and server environments.
After editing a schema file, generate and apply the migration:
# From packages/db-schema/
pnpm db:gen # generate migration SQL from schema changes
pnpm db:up # apply pending migrations to the database
pnpm db:studio # open Drizzle Studio UI for visual inspection
Migrations are output to packages/app/server/db/migrations/.
We highly recommend you take a look at the documentation to level up.
| Domain | Tables | Description |
|---|---|---|
| Users | users, sessions, accounts |
Authentication via better-auth |
| Rooms | rooms, roomMembers, roomRoles, roomInvites, roomBans |
Chat rooms + RBAC |
| Messages | messages (schema: message) |
Message metadata; content in Azure Table Storage |
| Posts | posts, postReactions |
Social feed posts |
| Achievements | achievements, userAchievements |
Gamification |
| Push | pushSubscriptions |
Web Push notification subscriptions |
| Friends | friendships, friendRequests |
Social graph |
pgTable wrapper (re-exported from this package), not raw drizzle pgTable — the wrapper adds standard metadata columns.z.discriminatedUnion schemas must end with satisfies z.ZodType<UnionType>.Run from packages/db-schema/:
pnpm db:gen # generate migration
pnpm db:up # apply migrations
pnpm db:studio # Drizzle Studio
pnpm build # compile to dist/
pnpm test # vitest watch mode
pnpm lint:fix # auto-fix lint
pnpm typecheck # type check
This project is licensed under the Apache-2.0 license.