Last active
September 29, 2023 16:31
-
-
Save aitseitz/57a52a10b75e469c05cda48b457d1652 to your computer and use it in GitHub Desktop.
ACS - Cleanup Alfresco Database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- PostgreSQL Script to delete ACS Database in case we do not have permissions to drop and create database | |
-- drop tables in 'public' schema | |
-- but do not delete sfc table! | |
DO $$ | |
DECLARE | |
r RECORD; | |
BEGIN | |
FOR r IN (select 'drop table if exists"' || tablename || '" cascade;' AS drop_statement from pg_tables WHERE schemaname = 'public' AND tablename != 'sfc') LOOP | |
EXECUTE r.drop_statement; | |
END LOOP; | |
END | |
$$; | |
-- drop sequences in 'public' schema | |
DO $$ | |
DECLARE | |
r RECORD; | |
BEGIN | |
FOR r IN (select 'drop sequence if exists"' || sequencename || '" cascade;' AS drop_statement from pg_sequences WHERE schemaname = 'public' AND sequencename NOT LIKE '%sfc%') LOOP | |
EXECUTE r.drop_statement; | |
END LOOP; | |
END | |
$$; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment