# Backup & migrate

ZPT production data lives in PostgreSQL. The Node API uses Prisma migrations under `server/prisma/migrations`.

## Backup

```bash
# From repo root (adjust connection to match .env DATABASE_URL)
pg_dump "$DATABASE_URL" -Fc -f zpt-$(date +%Y%m%d).dump
```

Restore:

```bash
pg_restore -d "$DATABASE_URL" --clean --if-exists zpt-YYYYMMDD.dump
```

Also back up the upload directory (`UPLOAD_DIR`, default `server/uploads`).

## Migrate

```bash
npm run migrate          # prisma migrate deploy (server)
# or
npm --prefix server run migrate:dev   # local iterative migrate
```

After migrate on a fresh database:

```bash
npm run seed
```

## Demo reset (non-production)

Super Admin → Configuration → **Reset Demo Data**, or:

```bash
curl -X POST http://localhost:4000/api/admin/reset-demo \
  -H "Authorization: Bearer $TOKEN"
```

Disabled when `NODE_ENV=production`.
