Docs

Search documentation

Jump to a documentation page.

PricingMarketingApp

Search documentation

Jump to a documentation page.

Seeding

Database seeding

What you already have

CommandWhat it does
pnpm db:seedWipes app tables (events, api_keys, subscriptions, organization_members, organizations, users) and inserts one baseline demo tenant: user, org, owner membership, active subscription (placeholder Stripe ids), one API key, and three analytics events.
pnpm db:seed:bulkSame reset + baseline, then adds extra workspaces with @faker-js/faker (more orgs, users, subscriptions, optional API keys, events).

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

  1. Migrate firstpnpm db:migrate so the schema matches packages/server/src/db/schema.ts.
  2. 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.ts uses Drizzle + postgres. No separate seed framework; extend in seed.ts and seed-bulk.ts.
  • Faker@faker-js/faker (devDependency) generates realistic labels for bulk rows only.
  • Drizzle Kitpnpm db:studio is 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.id is text without a DB default (Better Auth). Seeds set id with randomUUID() 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 users only. They do not get Better Auth accounts rows, so they cannot sign in; they exist to fill operator lists and metrics.
  • The demo user’s password_hash may 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.