feat(postgres): infrastructure setup and schema creation (tasks 1-2)

- Install pg (node-postgres) dependency
- Create backend/db.js connection pool module (max 10, auto-reconnect)
- Install Docker and spin up steam-postgres container on port 5433
- Create backend/db-schema.sql with complete Postgres DDL (24 tables)
- Replace findings_json blob with ivanti_findings table (individual rows)
- Merge notes/overrides into findings table columns
- Add proper indexes: state, bu_ownership, severity, composite
- Create backend/setup-postgres.js for idempotent schema initialization
- Add DATABASE_URL to .env and .env.example
- Update migration plan docs with Docker setup commands
- Verify: schema executes cleanly, pool connects, 24 tables created
This commit is contained in:
Jordan Ramos
2026-05-05 15:47:09 -06:00
parent 5cdca09f40
commit 845d843e71
6 changed files with 596 additions and 4 deletions

View File

@@ -258,3 +258,32 @@ systemctl start cve-backend
- **No JSON parsing**: Findings are rows, not a blob
- **Concurrent access**: Multiple users can read while sync writes
- **Future-proof**: Easy to add full-text search, materialized views, partitioning
## Docker Container Setup
Run this once to create the Postgres container:
```bash
docker run -d --name steam-postgres \
--restart unless-stopped \
-e POSTGRES_DB=cve_dashboard \
-e POSTGRES_USER=steam \
-e POSTGRES_PASSWORD=sV4xmC9xAUCFop0ypxMVS056QgPqGrX \
-p 5433:5432 \
-v steam-pgdata:/var/lib/postgresql/data \
postgres:16-alpine
```
Verify it's running:
```bash
docker ps | grep steam-postgres
psql -h localhost -p 5433 -U steam -d cve_dashboard -c "SELECT 1;"
```
Management commands:
```bash
docker stop steam-postgres # Stop
docker start steam-postgres # Start
docker logs steam-postgres # View logs
docker exec -it steam-postgres psql -U steam -d cve_dashboard # Shell access
```