Skip to main content

Database Setup & Maintenance

Ticku uses PostgreSQL with Prisma migrations. There is one shared database for the whole platform — all tenants live in it, isolated by a tenantId column and a tenant-scoped Prisma client (see Multi-Tenancy). There is no database-per-tenant.

Initial Setup

npm run db:migrate # apply all migrations (prisma migrate deploy)
npm run db:seed # seed baseline data

The seed is idempotent (uses upserts) — safe to re-run.

:::danger On real data, use migrate deploy only Against a database with real tenant data, apply schema changes with db:migrate (prisma migrate deploy) only. Never run db:push, db:seed destructively, or db:reset on production/staging — they can drop or overwrite tenant data. Migrations are applied manually to production, not by CI. :::

Available Scripts

ScriptPurpose
db:migrateApply pending migrations (production-safe)
db:migrate:devCreate + apply migrations (development)
db:seedSeed baseline data
db:studioOpen Prisma Studio (inspection — dev only)
db:resetDestructive — drop, recreate, reseed. Never in production.

Backups

For self-hosted Postgres:

docker compose exec db pg_dump -U <user> <dbname> | gzip > backup-$(date +%F).sql.gz

Schedule daily backups and test a restore at least once before go-live. Managed providers (Neon, Azure Database) include automated backups — verify retention meets the client's policy.

Restore

gunzip -c backup-2026-06-12.sql.gz | docker compose exec -T db psql -U <user> <dbname>