Remove static JSON files and seed step; migrate site settings to Postgres

All content (recipes + imprint/privacy settings) now lives exclusively in
Postgres. The app no longer requires a seed step on first deploy.

Changes:
- helpers.php: load_site_settings() returns defaults when site_settings
  table is empty instead of throwing DatabaseUnavailableException; removes
  legacy JSONB migration path
- data/recipes.json, data/site.json: deleted (content already in DB)
- scripts/db-seed.php: deleted (no longer needed)
- docker-compose.yml: remove RUN_DB_SEED env var and data/ volume mount
- docker/entrypoint.sh: remove RUN_DB_SEED seed block
- docs/COOLIFY.md: update deployment guide to reflect seedless workflow
- .claude/launch.json: add dev server configurations for preview tool

Fresh deploys now start with placeholder legal pages and an empty recipe
list; the admin fills in real content via /admin.php without any CLI step.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-18 09:53:39 +02:00
co-authored by Claude Sonnet 4.6
parent 792cbe18c1
commit 86fbd8e4bb
20 changed files with 154 additions and 512 deletions
+15 -12
View File
@@ -16,11 +16,11 @@ The project is architected to remain extremely lightweight and fast, intentional
- `login.php`: Local profile page for dietary goals and saved favorites (browser storage).
- **Support & Layouts**:
- `partials/`: Contains modular templates (`head.php`, `header.php`, `footer.php`) to maintain a clean DRY structure.
- `helpers.php`: Core PHP utilities and the PostgreSQL data access layer for recipes.
- `helpers.php`: Core PHP utilities and the PostgreSQL data access layer for recipes and site settings.
- `config.php`: Environment-independent configuration loader which reads runtime secrets from `.env`.
- `assets/fc-local.js`: Browser-side storage for favorites and dietary goals.
- `data/recipes.json`: Optional seed file only (`php scripts/db-seed.php`), not used at runtime.
- `scripts/schema.sql`: Relational table definitions for recipes.
- `scripts/seed-data.php`: One-time seed data for recipes, imprint, and privacy settings.
- `scripts/schema.sql`: Relational table definitions for recipes and site settings.
---
@@ -37,7 +37,7 @@ FlixCooks uses a modern, carefully curated vanilla tech-stack focused on lightni
### ⚙️ Backend & Data
- **Engine**: Vanilla PHP.
- **Database**: PostgreSQL only. `DATABASE_URL` is required; without a working DB connection the site returns HTTP 503.
- **Database**: PostgreSQL only. `DATABASE_URL` is required; without a working external DB connection the site returns HTTP 503.
- **Environment**: Custom `.env` variable parser integrated into PHP bootstrap.
---
@@ -58,7 +58,7 @@ Make sure you have the following installed on your local machine:
cp .env.example .env
```
2. Set **`DATABASE_URL`** in `.env` (required). See [Local Postgres (Docker)](#local-postgres-docker) below.
3. Seed recipes once: `php scripts/db-seed.php` (imports `data/recipes.json` into SQL tables).
3. Seed the external database once: `php scripts/db-seed.php` (imports recipes and legal/site settings into SQL tables).
### 2. Local Postgres (Docker)
@@ -97,7 +97,8 @@ Nützliche SQL-Befehle in `psql`:
\dt -- alle Tabellen
\d recipes -- Spalten der Tabelle recipes
SELECT slug, created_at FROM recipes;
SELECT slug, data->>'title' AS title FROM recipes, jsonb_to_record(data) AS x(title text); -- optional
SELECT recipe_slug, title FROM recipe_translations WHERE lang = 'en';
SELECT section, lang, setting_key FROM site_settings ORDER BY section, lang, setting_key;
\q -- beenden
```
@@ -135,7 +136,7 @@ If you prefer running a full local stack:
## 🗄️ Postgres in diesem Projekt (Kurzüberblick)
Rezepte liegen in **normalisierten SQL-Tabellen** (kein JSONB-Blob, kein Laufzeit-Fallback auf Dateien):
Rezepte und Site-Daten liegen in **normalisierten SQL-Tabellen**. Es gibt keinen JSONB-Blob, keinen Datei-Fallback und kein Laden von `data/*.json` zur Laufzeit.
| Tabelle | Inhalt |
|---------|--------|
@@ -145,19 +146,21 @@ Rezepte liegen in **normalisierten SQL-Tabellen** (kein JSONB-Blob, kein Laufzei
| `recipe_ingredients` | Zutatenzeilen |
| `recipe_utensils` | Werkzeugzeilen |
| `recipe_steps` | Schritte inkl. Video-URL und Timer |
| `site_settings` | Impressum- und Datenschutzfelder pro Sprache |
Schema: `scripts/schema.sql`. PHP baut daraus dieselben Arrays wie früher (`i18n.en`, `nutrition`, …), damit Templates unverändert bleiben.
**Ablauf:**
1. `DATABASE_URL` in `.env` → Verbindung über `config.php`.
2. Beim ersten Request: Tabellen anlegen (`ensure_recipe_schema()`). Alte JSONB-Tabelle wird einmalig migriert.
3. `load_recipes()` liest per SQL; ohne DB → HTTP 503 (`maintenance/db-unavailable.php`).
4. Admin: `save_recipe()` / `delete_recipe()` direkt in die Tabellen.
2. Beim ersten Request: Tabellen anlegen (`ensure_recipe_schema()`).
3. `php scripts/db-seed.php` einmalig ausführen → Rezepte und Site-Daten werden in Postgres geschrieben.
4. `load_recipes()` und `load_site_settings()` lesen per SQL; ohne DB → HTTP 503 (`maintenance/db-unavailable.php`).
5. Admin: `save_recipe()`, `delete_recipe()` und `save_site_settings()` schreiben direkt in die Tabellen.
**Einmalig Daten laden:** `php scripts/db-seed.php` (aus `data/recipes.json`).
**Einmalig Daten laden:** `php scripts/db-seed.php` (aus `scripts/seed-data.php`, ohne JSON-Dateien).
Für **Staging/Production** nur `DATABASE_URL` in der Hosting-Umgebung setzen nie Production-Daten in der lokalen Dev-DB mischen.
Für **Staging/Production** muss eine externe Postgres-Datenbank vorhanden sein. Setze nur `DATABASE_URL` in der Hosting-Umgebung und mische nie Production-Daten in die lokale Dev-DB.
### Docker / Coolify