# Database seed

## Schema (EF EnsureCreated + migration file)

- **Users** — Id, Email, DisplayName, PasswordHash, Role, IsActive, CreatedAt, Theme
- **Roles** — User, Administrator, MasterDeveloper
- **AuditLogs** — Id, EventType, UserId, Message, CreatedAt
- **RefreshTokens** — existing POC table

Migration reference: `source/nexus-identity/NexusIdentity.Api/Migrations/20260604194500_InitialCreate.cs`

## Seed behaviour

Controlled by `NEXUS_SEED_POC_USERS`:

| Value | Behaviour |
|-------|-----------|
| `true` | Seed POC users if Users table is empty |
| `false` | No test users seeded |

## PostgreSQL vs SQLite

- **Coolify nexus-db:** PostgreSQL created; health was unstable during setup
- **Backend POC deploy:** Uses `NEXUS_DB_CONNECTION=Data Source=/app/nexus.db` (SQLite in container) until Postgres is healthy and linked

## Manual Postgres link (Coolify UI)

1. Open **nexus-backend** → Connect database → **nexus-db**
2. Set `NEXUS_DB_CONNECTION` from Coolify injected URL (never commit)
3. Redeploy backend
