Skip to content

Commit

Permalink
fixup! refact(db): Replace get_deleted_tables function with a view
Browse files Browse the repository at this point in the history
  • Loading branch information
tmessi committed Sep 16, 2024
1 parent 32bcc2a commit 4964762
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 4964762

Please sign in to comment.