Seeding
Database seeding
What you already have
Optional env:
SEED_BULK_ORGS— number of extra organizations to create with bulk seed (default 6, max 25).
Examples:
# .env must define DATABASE_URL
pnpm db:migrate
pnpm db:seed
# Heavier demo data for /admin and charts
SEED_BULK_ORGS=12 pnpm db:seed:bulk
Requirements
- Migrate first —
pnpm db:migrateso the schema matchespackages/server/src/db/schema.ts. DATABASE_URL— same Postgres URL the app uses (local Docker, Supabase pooler, etc.).
Libraries vs “local script”
- Local script (current approach) —
packages/server/src/db/seed.tsuses Drizzle +postgres. No separate seed framework; extend inseed.tsandseed-bulk.ts. - Faker —
@faker-js/faker(devDependency) generates realistic labels for bulk rows only. - Drizzle Kit —
pnpm db:studiois useful to inspect data after seeding; it does not replace a seed script. - Supabase — You can run SQL in the SQL editor or use the CLI; the repo still recommends the TypeScript seed so schema + types stay in sync.
Important limitations
users.idistextwithout a DB default (Better Auth). Seeds setidwithrandomUUID()so inserts succeed. Sign-ups still get an id from Better Auth.- Full reset deletes all rows in the listed tables. Do not run against production.
- Bulk users are inserted into
usersonly. They do not get Better Authaccountsrows, so they cannot sign in; they exist to fill operator lists and metrics. - The demo user’s
password_hashmay be a placeholder. If sign-in fails, replace it with a real bcrypt hash or sign up through the UI and skip wiping that user.
Files
packages/server/src/db/seed.ts— entrypoint and baseline dataset.packages/server/src/db/seed-bulk.ts— optional Faker-powered extras.