cms: Schema-Migration bei jedem up nachziehen (forums/threads in Bestands-DB)
Problem: Init-Scripts (docker-entrypoint-initdb.d) laufen nur beim allerersten DB-Start. Neue Tabellen aus schema.sql (forums/threads) landeten daher nicht in einer bereits initialisierten Produktiv-DB → "relation public.forums does not exist" auf der Dialog-Seite. - docker-compose.yml: neuer einmaliger `migrate`-Service spielt das idempotente schema.sql als supabase_admin (Superuser, keine Owner-Konflikte) bei jedem `up` ein und lädt den PostgREST-Cache neu; cms wartet via service_completed_successfully darauf. - routes/dialog.js: fehlende Tabelle führt nicht mehr zu rohem SQL-Fehler — leere Liste + server-seitiges Log statt 500 auf der Seite. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -41,6 +41,30 @@ services:
|
||||
retries: 20
|
||||
start_period: 30s
|
||||
|
||||
# ════════════════════════════════════════════════════════════════════════
|
||||
# Migrate — spielt das (idempotente) Schema bei jedem `up` nach, damit neue
|
||||
# Tabellen/Spalten auch in eine BESTEHENDE DB kommen (Init-Scripts laufen nur
|
||||
# beim allerersten Start). Läuft einmal und beendet sich. supabase_admin =
|
||||
# Superuser → keine Owner-Konflikte. schema.sql ist idempotent.
|
||||
# ════════════════════════════════════════════════════════════════════════
|
||||
migrate:
|
||||
image: supabase/postgres:15.8.1.020
|
||||
container_name: openbureau-migrate
|
||||
restart: "no"
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
PGPASSWORD: ${POSTGRES_PASSWORD}
|
||||
volumes:
|
||||
- ./db/schema.sql:/openbureau-schema.sql:ro
|
||||
entrypoint: ["bash", "-c"]
|
||||
command:
|
||||
- >
|
||||
psql -h db -U supabase_admin -d postgres -v ON_ERROR_STOP=1 -f /openbureau-schema.sql &&
|
||||
psql -h db -U supabase_admin -d postgres -c "notify pgrst, 'reload schema';" &&
|
||||
echo '✓ Schema migriert.'
|
||||
|
||||
# ════════════════════════════════════════════════════════════════════════
|
||||
# GoTrue — Auth (Login für das CMS)
|
||||
# ════════════════════════════════════════════════════════════════════════
|
||||
@@ -124,6 +148,8 @@ services:
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
kong:
|
||||
condition: service_started
|
||||
environment:
|
||||
|
||||
Reference in New Issue
Block a user