This file contains 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
CREATE OR REPLACE FUNCTION rebuild_view() RETURNS event_trigger AS | |
$rebuild_view$ | |
DECLARE | |
table_name text; | |
view_name text; | |
BEGIN | |
SELECT object_identity INTO table_name FROM pg_event_trigger_ddl_commands() LIMIT 1; | |
SELECT split_part(table_name, '.', 1) || '.v_' || split_part(table_name, '.', 2) | |
INTO view_name; | |
EXECUTE 'DROP VIEW IF EXISTS ' || view_name; |