SQL Queries for tests
Delete test tenants schemes
Somehow during deletion of tenants their schemas are deleted.
Use this SQL query to create a query to find and drop all schemas.
We assume that your pattern for test tenant is testtenant{digits}
select 'drop schema if exists ' || string_agg(schema_name, ', ') || ' cascade'
from (select schema_name from information_schema.schemata where schema_name similar to 'testtenant\d%')
It will create another sql query that you need to use to actually drop schemas. It will drop all items within them.