mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2026-07-17 14:15:13 +00:00
fix(restore): drop user-owned collations in the --empty pre-clean
The drop_sql loop covered relations, routines, sequences and types but not pg_collation, so a dump's CREATE COLLATION (OpenProject's ICU public.versions_name) aborted the ON_ERROR_STOP replay with 'collation already exists'. Add the fifth UNION ALL branch; DROP COLLATION IF EXISTS public.<name> CASCADE rides the existing loop, and the loop already drops every user table, so CASCADE fallout is absorbed by the IF EXISTS no-ops. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -88,6 +88,11 @@ BEGIN
|
||||
OR (t.typtype = 'c' AND EXISTS (
|
||||
SELECT 1 FROM pg_class c2
|
||||
WHERE c2.oid = t.typrelid AND c2.relkind = 'c')))
|
||||
UNION ALL
|
||||
SELECT col.collname AS name, 'COLLATION' AS type
|
||||
FROM pg_collation col JOIN pg_namespace n ON n.oid = col.collnamespace
|
||||
WHERE n.nspname = 'public'
|
||||
AND pg_get_userbyid(col.collowner) = current_user
|
||||
) LOOP
|
||||
EXECUTE format('DROP %s IF EXISTS public.%I CASCADE', r.type, r.name);
|
||||
END LOOP;
|
||||
|
||||
Reference in New Issue
Block a user