docs(deployment): add verified full reset procedure to Hetzner guide
Some checks failed
CI / pytest (push) Failing after 48m4s
CI / validate (push) Successful in 25s
CI / ruff (push) Successful in 11s
CI / dependency-scanning (push) Successful in 29s
CI / docs (push) Has been skipped
CI / deploy (push) Has been skipped

Document the complete nuclear reset sequence (tested end-to-end):
stop → build → infra up → schema reset → migrations → seeds → start.
Update seeded data counts to match current output (30 CMS pages,
12 tiers, 3 admins, 28 email templates). Switch from exec to run --rm
for seed commands so they work before services are started.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-01 23:21:52 +01:00
parent 6dec1e3ca6
commit 05c53e1865

View File

@@ -483,29 +483,81 @@ Expected: `api` (healthy), `db` (healthy), `redis` (healthy), `celery-worker` (h
!!! note "PYTHONPATH required" !!! note "PYTHONPATH required"
The seed scripts need `PYTHONPATH=/app` set explicitly when running inside the container. The seed scripts need `PYTHONPATH=/app` set explicitly when running inside the container.
Use `run --rm` (not `exec`) if the api service is not yet running.
### First-time initialization
```bash ```bash
# Run migrations (use 'heads' for multi-branch Alembic) # Run migrations (use 'heads' for multi-branch Alembic)
docker compose --profile full exec -e PYTHONPATH=/app api python -m alembic upgrade heads docker compose --profile full run --rm -e PYTHONPATH=/app api alembic upgrade heads
# Seed production data # Seed production data (order matters)
docker compose --profile full exec -e PYTHONPATH=/app api python scripts/seed/init_production.py docker compose --profile full run --rm -e PYTHONPATH=/app api python scripts/seed/init_production.py
docker compose --profile full exec -e PYTHONPATH=/app api python scripts/seed/init_log_settings.py docker compose --profile full run --rm -e PYTHONPATH=/app api python scripts/seed/init_log_settings.py
docker compose --profile full exec -e PYTHONPATH=/app api python scripts/seed/create_default_content_pages.py docker compose --profile full run --rm -e PYTHONPATH=/app api python scripts/seed/create_default_content_pages.py
docker compose --profile full exec -e PYTHONPATH=/app api python scripts/seed/seed_email_templates.py docker compose --profile full run --rm -e PYTHONPATH=/app api python scripts/seed/seed_email_templates.py
```
### Full reset procedure (nuclear — deletes all data)
Use this to reset the database from scratch. Stop workers first to avoid task conflicts.
```bash
# 1. Stop everything
docker compose --profile full down
# 2. Rebuild ALL images (picks up latest code)
docker compose --profile full build
# 3. Start infrastructure only
docker compose up -d db redis
# 4. Wait for healthy
docker compose exec db pg_isready -U orion_user -d orion_db
docker compose exec redis redis-cli ping
# 5. Drop and recreate schema
docker compose --profile full run --rm -e PYTHONPATH=/app api python -c "
from app.core.config import settings
from sqlalchemy import create_engine, text
e = create_engine(settings.database_url)
c = e.connect()
c.execute(text('DROP SCHEMA IF EXISTS public CASCADE'))
c.execute(text('CREATE SCHEMA public'))
c.commit()
c.close()
print('Schema reset complete')
"
# 6. Run migrations
docker compose --profile full run --rm -e PYTHONPATH=/app api alembic upgrade heads
# 7. Seed in order
docker compose --profile full run --rm -e PYTHONPATH=/app api python scripts/seed/init_production.py
docker compose --profile full run --rm -e PYTHONPATH=/app api python scripts/seed/init_log_settings.py
docker compose --profile full run --rm -e PYTHONPATH=/app api python scripts/seed/create_default_content_pages.py
docker compose --profile full run --rm -e PYTHONPATH=/app api python scripts/seed/seed_email_templates.py
# 8. Start all services
docker compose --profile full up -d
# 9. Verify
docker compose --profile full ps
docker stats --no-stream --format "table {{.Name}}\t{{.MemUsage}}\t{{.MemPerc}}"
``` ```
### Seeded Data Summary ### Seeded Data Summary
| Data | Count | | Data | Count |
|---|---| |---|---|
| Admin users | 1 (`admin@wizard.lu`) | | Admin users | 3 (super admin + OMS admin + Loyalty admin) |
| Platforms | 3 (OMS, Main, Loyalty+) | | Platforms | 3 (OMS, Wizard, Loyalty) |
| Platform modules | 57 |
| Admin settings | 15 | | Admin settings | 15 |
| Subscription tiers | 4 (Essential, Professional, Business, Enterprise) | | Subscription tiers | 12 (4 per platform: Essential, Professional, Business, Enterprise) |
| Log settings | 6 | | Log settings | 6 |
| CMS pages | 8 (About, Contact, FAQ, Shipping, Returns, Privacy, Terms, Homepage) | | CMS pages | 30 (platform homepages + marketing pages + store defaults) |
| Email templates | 17 (4 languages: en, fr, de, lb) | | Email templates | 28 (4 languages: en, fr, de, lb) |
--- ---