Docker-Fix: DB-Init bricht bei CREATE SCHEMA public nicht mehr ab, Port 5433 statt 5432
This commit is contained in:
@@ -73,7 +73,7 @@ PostgreSQL müssen nicht installiert sein):
|
|||||||
```bash
|
```bash
|
||||||
docker compose --env-file .env.local up -d --build
|
docker compose --env-file .env.local up -d --build
|
||||||
# App: Port 3000 (hinter Reverse-Proxy mit HTTPS betreiben)
|
# App: Port 3000 (hinter Reverse-Proxy mit HTTPS betreiben)
|
||||||
# Lokale DB-Kopie: Port 5432 (Dienst "db", optional)
|
# Lokale DB-Kopie: Port 5433 (Dienst "db", optional)
|
||||||
```
|
```
|
||||||
|
|
||||||
Oder klassisch ohne Docker:
|
Oder klassisch ohne Docker:
|
||||||
@@ -121,7 +121,8 @@ Minimal-Stubs für `auth`/`storage`) gibt es in zwei Varianten:
|
|||||||
|
|
||||||
**Per Docker:** Der Dienst `db` aus `docker-compose.yml` spielt die
|
**Per Docker:** Der Dienst `db` aus `docker-compose.yml` spielt die
|
||||||
Skripte aus `supabase/local/` beim ersten Start automatisch ein
|
Skripte aus `supabase/local/` beim ersten Start automatisch ein
|
||||||
(PostgreSQL 17, Port 5432, Passwort über `LOCAL_PG_PASSWORD`).
|
(PostgreSQL 17, Host-Port 5433 – 5432 ist meist durch eine native
|
||||||
|
PostgreSQL-Installation belegt –, Passwort über `LOCAL_PG_PASSWORD`).
|
||||||
|
|
||||||
**Nativ:** Auf dem Entwicklungsrechner läuft PostgreSQL 17 mit derselben
|
**Nativ:** Auf dem Entwicklungsrechner läuft PostgreSQL 17 mit derselben
|
||||||
Datenbank. Neu aufbauen bzw. aktualisieren:
|
Datenbank. Neu aufbauen bzw. aktualisieren:
|
||||||
|
|||||||
+3
-1
@@ -36,7 +36,9 @@ services:
|
|||||||
POSTGRES_DB: speisekarte
|
POSTGRES_DB: speisekarte
|
||||||
POSTGRES_PASSWORD: ${LOCAL_PG_PASSWORD:-speisekarte}
|
POSTGRES_PASSWORD: ${LOCAL_PG_PASSWORD:-speisekarte}
|
||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
# Host-Port 5433, da 5432 meist schon von einer nativen
|
||||||
|
# PostgreSQL-Installation belegt ist.
|
||||||
|
- "5433:5432"
|
||||||
volumes:
|
volumes:
|
||||||
- pgdata:/var/lib/postgresql/data
|
- pgdata:/var/lib/postgresql/data
|
||||||
- ./supabase/local:/docker-entrypoint-initdb.d:ro
|
- ./supabase/local:/docker-entrypoint-initdb.d:ro
|
||||||
|
|||||||
@@ -18,13 +18,23 @@ if (-not $env:LOCAL_PG_PASSWORD) { throw "LOCAL_PG_PASSWORD ist nicht gesetzt
|
|||||||
|
|
||||||
# 1. Aktuellen Stand aus Supabase ziehen (Session-Pooler, Port 5432)
|
# 1. Aktuellen Stand aus Supabase ziehen (Session-Pooler, Port 5432)
|
||||||
$env:PGPASSWORD = $env:SUPABASE_DB_PASSWORD
|
$env:PGPASSWORD = $env:SUPABASE_DB_PASSWORD
|
||||||
|
$SchemaFile = Join-Path $LocalDir "10_schema.sql"
|
||||||
& "$PgBin\pg_dump" -h $RemoteHost -p 5432 -U $RemoteUser -d postgres `
|
& "$PgBin\pg_dump" -h $RemoteHost -p 5432 -U $RemoteUser -d postgres `
|
||||||
--schema=public --schema-only --no-owner --no-privileges `
|
--schema=public --schema-only --no-owner --no-privileges `
|
||||||
-f (Join-Path $LocalDir "10_schema.sql")
|
-f $SchemaFile
|
||||||
& "$PgBin\pg_dump" -h $RemoteHost -p 5432 -U $RemoteUser -d postgres `
|
& "$PgBin\pg_dump" -h $RemoteHost -p 5432 -U $RemoteUser -d postgres `
|
||||||
--schema=public --data-only --no-owner --disable-triggers `
|
--schema=public --data-only --no-owner --disable-triggers `
|
||||||
-f (Join-Path $LocalDir "20_data.sql")
|
-f (Join-Path $LocalDir "20_data.sql")
|
||||||
|
|
||||||
|
# pg_dump legt "CREATE SCHEMA public;" und \restrict/\unrestrict-Marker an.
|
||||||
|
# Das offizielle postgres-Docker-Image besitzt "public" bereits und bricht
|
||||||
|
# mit ON_ERROR_STOP=1 sonst das komplette Init-Skript ab.
|
||||||
|
(Get-Content $SchemaFile) `
|
||||||
|
-replace '^CREATE SCHEMA public;$', 'CREATE SCHEMA IF NOT EXISTS public;' `
|
||||||
|
-replace '^\\restrict .*$', '' `
|
||||||
|
-replace '^\\unrestrict .*$', '' |
|
||||||
|
Set-Content $SchemaFile
|
||||||
|
|
||||||
# 2. Lokale Datenbank neu aufbauen
|
# 2. Lokale Datenbank neu aufbauen
|
||||||
$env:PGPASSWORD = $env:LOCAL_PG_PASSWORD
|
$env:PGPASSWORD = $env:LOCAL_PG_PASSWORD
|
||||||
& "$PgBin\psql" -h localhost -U postgres -c "drop database if exists speisekarte;"
|
& "$PgBin\psql" -h localhost -U postgres -c "drop database if exists speisekarte;"
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
-- PostgreSQL database dump
|
-- PostgreSQL database dump
|
||||||
--
|
--
|
||||||
|
|
||||||
\restrict 0Sx6NoZQaGnfPJIJyJfoBWP8AEmM74wz3Ic4g8Y4DFplRk7HfQrhCEYG288Lc2B
|
|
||||||
|
|
||||||
-- Dumped from database version 17.6
|
-- Dumped from database version 17.6
|
||||||
-- Dumped by pg_dump version 17.10
|
-- Dumped by pg_dump version 17.10
|
||||||
|
|
||||||
@@ -23,7 +21,10 @@ SET row_security = off;
|
|||||||
-- Name: public; Type: SCHEMA; Schema: -; Owner: -
|
-- Name: public; Type: SCHEMA; Schema: -; Owner: -
|
||||||
--
|
--
|
||||||
|
|
||||||
CREATE SCHEMA public;
|
-- Das "public"-Schema existiert im offiziellen postgres-Image bereits;
|
||||||
|
-- CREATE SCHEMA würde dort mit ON_ERROR_STOP=1 das komplette Init-Skript
|
||||||
|
-- abbrechen.
|
||||||
|
CREATE SCHEMA IF NOT EXISTS public;
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
@@ -412,5 +413,3 @@ CREATE POLICY settings_public_read ON public.settings FOR SELECT TO authenticate
|
|||||||
-- PostgreSQL database dump complete
|
-- PostgreSQL database dump complete
|
||||||
--
|
--
|
||||||
|
|
||||||
\unrestrict 0Sx6NoZQaGnfPJIJyJfoBWP8AEmM74wz3Ic4g8Y4DFplRk7HfQrhCEYG288Lc2B
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user