From 05c53e18650aa64b35f7d4900118222a22fff7b5 Mon Sep 17 00:00:00 2001 From: Samir Boulahtit Date: Sun, 1 Mar 2026 23:21:52 +0100 Subject: [PATCH] docs(deployment): add verified full reset procedure to Hetzner guide MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- docs/deployment/hetzner-server-setup.md | 74 +++++++++++++++++++++---- 1 file changed, 63 insertions(+), 11 deletions(-) diff --git a/docs/deployment/hetzner-server-setup.md b/docs/deployment/hetzner-server-setup.md index c980639d..725e7631 100644 --- a/docs/deployment/hetzner-server-setup.md +++ b/docs/deployment/hetzner-server-setup.md @@ -483,29 +483,81 @@ Expected: `api` (healthy), `db` (healthy), `redis` (healthy), `celery-worker` (h !!! note "PYTHONPATH required" 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 # 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 -docker compose --profile full exec -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 exec -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 +# Seed production data (order matters) +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 +``` + +### 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 | Data | Count | |---|---| -| Admin users | 1 (`admin@wizard.lu`) | -| Platforms | 3 (OMS, Main, Loyalty+) | +| Admin users | 3 (super admin + OMS admin + Loyalty admin) | +| Platforms | 3 (OMS, Wizard, Loyalty) | +| Platform modules | 57 | | Admin settings | 15 | -| Subscription tiers | 4 (Essential, Professional, Business, Enterprise) | +| Subscription tiers | 12 (4 per platform: Essential, Professional, Business, Enterprise) | | Log settings | 6 | -| CMS pages | 8 (About, Contact, FAQ, Shipping, Returns, Privacy, Terms, Homepage) | -| Email templates | 17 (4 languages: en, fr, de, lb) | +| CMS pages | 30 (platform homepages + marketing pages + store defaults) | +| Email templates | 28 (4 languages: en, fr, de, lb) | ---