Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aitseitz/57a52a10b75e469c05cda48b457d1652 to your computer and use it in GitHub Desktop.
Save aitseitz/57a52a10b75e469c05cda48b457d1652 to your computer and use it in GitHub Desktop.
ACS - Cleanup Alfresco Database
-- 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