diff --git a/internal/db/schema/migrations/oss/postgres/91/05_deletion_tables_view.up.sql b/internal/db/schema/migrations/oss/postgres/91/05_deletion_tables_view.up.sql index 82b5cad9ae..ccdf35647c 100644 --- a/internal/db/schema/migrations/oss/postgres/91/05_deletion_tables_view.up.sql +++ b/internal/db/schema/migrations/oss/postgres/91/05_deletion_tables_view.up.sql @@ -6,10 +6,13 @@ begin; -- This is being replaced with a view. drop function get_deletion_tables; + -- This view uses the pg_catalog to find all tables that end in _deleted and are visibile. + -- See: https://www.postgresql.org/docs/current/catalog-pg-class.html + -- https://www.postgresql.org/docs/current/functions-info.html#FUNCTIONS-INFO-SCHEMA create view deletion_table as select c.relname as tablename from pg_catalog.pg_class c - where c.relkind in ('r') + where c.relkind in ('r') -- r = ordinary table and c.relname operator(pg_catalog.~) '^(.+_deleted)$' collate pg_catalog.default and pg_catalog.pg_table_is_visible(c.oid); commit;