- Restore blue PageHeader on Dashboard (/app-components) - Update homepage (/) with subtle header design without blue bar - Add uniform PageHeader styling to application edit page - Fix Rapporten link on homepage to point to /reports overview - Improve header descriptions spacing for better readability
186 lines
3.7 KiB
Markdown
186 lines
3.7 KiB
Markdown
# PostgreSQL Database Reset (Lokaal)
|
|
|
|
## Quick Reset
|
|
|
|
Om de PostgreSQL database volledig te resetten (green field simulatie):
|
|
|
|
```bash
|
|
# Option 1: Gebruik het reset script
|
|
./scripts/reset-postgres.sh
|
|
```
|
|
|
|
## Handmatige Reset
|
|
|
|
Als je het handmatig wilt doen:
|
|
|
|
### Stap 1: Stop Containers
|
|
|
|
```bash
|
|
docker-compose down
|
|
```
|
|
|
|
### Stap 2: Verwijder PostgreSQL Volume
|
|
|
|
```bash
|
|
# Check volumes
|
|
docker volume ls | grep postgres
|
|
|
|
# Verwijder volume (dit verwijdert ALLE data!)
|
|
docker volume rm cmdb-insight_postgres_data
|
|
```
|
|
|
|
**Let op:** Dit verwijdert alle data permanent!
|
|
|
|
### Stap 3: Start Containers Opnieuw
|
|
|
|
```bash
|
|
docker-compose up -d postgres
|
|
```
|
|
|
|
### Stap 4: Wacht tot PostgreSQL Ready is
|
|
|
|
```bash
|
|
# Check status
|
|
docker-compose ps
|
|
|
|
# Test connection
|
|
docker-compose exec postgres pg_isready -U cmdb
|
|
```
|
|
|
|
### Stap 5: Maak Databases Aan (Optioneel)
|
|
|
|
De applicatie maakt databases automatisch aan, maar je kunt ze ook handmatig aanmaken:
|
|
|
|
```bash
|
|
docker-compose exec postgres psql -U cmdb -c "CREATE DATABASE cmdb_cache;"
|
|
docker-compose exec postgres psql -U cmdb -c "CREATE DATABASE cmdb_classifications;"
|
|
```
|
|
|
|
## Verificatie
|
|
|
|
Na reset, check of alles werkt:
|
|
|
|
```bash
|
|
# Connect to database
|
|
docker-compose exec postgres psql -U cmdb -d cmdb_cache
|
|
|
|
# Check tables (zou leeg moeten zijn)
|
|
\dt
|
|
|
|
# Exit
|
|
\q
|
|
```
|
|
|
|
## Wat Gebeurt Er Bij Reset?
|
|
|
|
1. **Alle data wordt verwijderd** - Alle tabellen, objecten, relaties
|
|
2. **Volume wordt verwijderd** - PostgreSQL data directory wordt gewist
|
|
3. **Nieuwe database** - Bij volgende start is het een schone database
|
|
4. **Schema wordt automatisch aangemaakt** - Bij eerste start van backend
|
|
|
|
## Na Reset
|
|
|
|
1. **Start backend:**
|
|
```bash
|
|
docker-compose up -d backend
|
|
```
|
|
|
|
2. **Check logs:**
|
|
```bash
|
|
docker-compose logs -f backend
|
|
```
|
|
|
|
Je zou moeten zien:
|
|
- "NormalizedCacheStore: Database schema initialized"
|
|
- "SchemaDiscovery: Schema discovery complete"
|
|
|
|
3. **Schema genereren (als nodig):**
|
|
```bash
|
|
docker-compose exec backend npm run generate-schema
|
|
```
|
|
|
|
4. **Start sync:**
|
|
- Via UI: Settings → Cache Management → Full Sync
|
|
- Of via API: `POST /api/cache/sync`
|
|
|
|
## Troubleshooting
|
|
|
|
### Volume niet gevonden
|
|
|
|
```bash
|
|
# Check alle volumes
|
|
docker volume ls
|
|
|
|
# Zoek naar postgres volume
|
|
docker volume ls | grep postgres
|
|
```
|
|
|
|
### Database bestaat al
|
|
|
|
Als je een fout krijgt dat de database al bestaat:
|
|
```bash
|
|
# Drop en recreate
|
|
docker-compose exec postgres psql -U cmdb -c "DROP DATABASE IF EXISTS cmdb_cache;"
|
|
docker-compose exec postgres psql -U cmdb -c "CREATE DATABASE cmdb_cache;"
|
|
```
|
|
|
|
### Connection Issues
|
|
|
|
```bash
|
|
# Check of PostgreSQL draait
|
|
docker-compose ps postgres
|
|
|
|
# Check logs
|
|
docker-compose logs postgres
|
|
|
|
# Test connection
|
|
docker-compose exec postgres pg_isready -U cmdb
|
|
```
|
|
|
|
## Environment Variables
|
|
|
|
Zorg dat je `.env` bestand correct is:
|
|
|
|
```env
|
|
DATABASE_TYPE=postgres
|
|
DATABASE_HOST=postgres
|
|
DATABASE_PORT=5432
|
|
DATABASE_NAME=cmdb_cache
|
|
DATABASE_USER=cmdb
|
|
DATABASE_PASSWORD=cmdb-dev
|
|
```
|
|
|
|
Of gebruik connection string:
|
|
|
|
```env
|
|
DATABASE_TYPE=postgres
|
|
DATABASE_URL=postgresql://cmdb:cmdb-dev@postgres:5432/cmdb_cache
|
|
```
|
|
|
|
## Snelle Commando's
|
|
|
|
```bash
|
|
# Alles in één keer
|
|
docker-compose down && \
|
|
docker volume rm cmdb-insight_postgres_data && \
|
|
docker-compose up -d postgres && \
|
|
sleep 5 && \
|
|
docker-compose exec postgres pg_isready -U cmdb
|
|
|
|
# Check database size (na sync)
|
|
docker-compose exec postgres psql -U cmdb -d cmdb_cache -c "
|
|
SELECT
|
|
pg_size_pretty(pg_database_size('cmdb_cache')) as size;
|
|
"
|
|
|
|
# List all tables
|
|
docker-compose exec postgres psql -U cmdb -d cmdb_cache -c "\dt"
|
|
|
|
# Count objects
|
|
docker-compose exec postgres psql -U cmdb -d cmdb_cache -c "
|
|
SELECT object_type_name, COUNT(*)
|
|
FROM objects
|
|
GROUP BY object_type_name;
|
|
"
|
|
```
|