Skip to content

Commit 131347c

Browse files
author
Fabian Martinez
authored
Improve pg cleanup (#1855)
* mas ci: improve postgresql cleanup * clean sequences
1 parent 95c3e99 commit 131347c

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

pr_check_docker.sh

100644100755
File mode changed.

scripts/clean-postgres.sql

+18-19
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
DROP TABLE apicurio;
1+
SELECT schemaname, tablename, tableowner FROM pg_tables WHERE schemaname = 'public';
22

3-
DROP SEQUENCE contentidsequence;
4-
DROP SEQUENCE globalidsequence;
3+
DO $$ DECLARE
4+
r RECORD;
5+
BEGIN
6+
FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = 'public') LOOP
7+
EXECUTE 'DROP TABLE IF EXISTS ' || quote_ident(r.tablename) || ' CASCADE';
8+
END LOOP;
9+
END $$;
510

6-
DROP TABLE globalrules;
11+
SELECT schemaname, tablename, tableowner FROM pg_tables WHERE schemaname = 'public';
712

8-
DROP TABLE artifacts CASCADE;
13+
SELECT relname FROM pg_class WHERE relkind = 'S';
914

10-
DROP TABLE rules CASCADE;
15+
DO $$ DECLARE
16+
r RECORD;
17+
BEGIN
18+
FOR r IN (SELECT relname FROM pg_class WHERE relkind = 'S') LOOP
19+
EXECUTE 'DROP SEQUENCE IF EXISTS ' || quote_ident(r.relname) || ' CASCADE';
20+
END LOOP;
21+
END $$;
1122

12-
DROP TABLE content CASCADE;
13-
14-
DROP TABLE versions CASCADE;
15-
16-
DROP TABLE properties CASCADE;
17-
18-
DROP TABLE labels CASCADE;
19-
20-
DROP TABLE logconfiguration;
21-
22-
DROP TABLE groups;
23-
24-
DROP TABLE acls;
23+
SELECT relname FROM pg_class WHERE relkind = 'S';

0 commit comments

Comments
 (0)