Skip to content

Commit 5fe23f2

Browse files
droserasproutWizard1209
authored andcommitted
Cover more function and type types
1 parent 52ee84f commit 5fe23f2

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/dipdup/sql/dipdup_wipe.sql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
-- Drops all user-defined objects in the specified schema. A complete schema wipe without dropping the schema itself.
22
-- Affects views, materialized views, tables (including hypertables), sequences, composite types, functions, and procedures.
33
-- This functionality was implemented for compatibility with some cloud provider I can't remember, who doesn't allow dropping schemas directly.
4+
-- Should work with PostgreSQL 11+ and TimescaleDB 2.0+.
45
CREATE OR REPLACE FUNCTION dipdup_wipe(schema_name VARCHAR) RETURNS void AS $$
56
DECLARE
67
rec RECORD;
@@ -43,7 +44,7 @@ BEGIN
4344
FROM pg_type t
4445
JOIN pg_namespace n ON n.oid = t.typnamespace
4546
WHERE n.nspname = schema_name
46-
AND t.typtype = 'c'
47+
AND t.typtype IN ('c', 'e', 'd', 'r')
4748
AND NOT EXISTS (
4849
SELECT 1 FROM pg_depend d
4950
WHERE d.classid = 'pg_type'::regclass
@@ -62,7 +63,7 @@ BEGIN
6263
FROM pg_proc p
6364
JOIN pg_namespace n ON n.oid = p.pronamespace
6465
WHERE n.nspname = schema_name
65-
AND p.prokind IN ('f', 'p')
66+
AND p.prokind IN ('f', 'p', 'a', 'w')
6667
AND NOT EXISTS (
6768
SELECT 1 FROM pg_depend d
6869
WHERE d.classid = 'pg_proc'::regclass

0 commit comments

Comments
 (0)