Docker-Fix: DB-Init bricht bei CREATE SCHEMA public nicht mehr ab, Port 5433 statt 5432
This commit is contained in:
@@ -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)
|
||||
$env:PGPASSWORD = $env:SUPABASE_DB_PASSWORD
|
||||
$SchemaFile = Join-Path $LocalDir "10_schema.sql"
|
||||
& "$PgBin\pg_dump" -h $RemoteHost -p 5432 -U $RemoteUser -d postgres `
|
||||
--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 `
|
||||
--schema=public --data-only --no-owner --disable-triggers `
|
||||
-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
|
||||
$env:PGPASSWORD = $env:LOCAL_PG_PASSWORD
|
||||
& "$PgBin\psql" -h localhost -U postgres -c "drop database if exists speisekarte;"
|
||||
|
||||
Reference in New Issue
Block a user