I want to \"create or replace\" a trigger for a postgres table. However, there is not such sql expression.
I see that I can do a \"DROP TRIGGER IF EXISTS
\"
You can combine CREATE OR REPLACE FUNCTION trigger_function
with the following script in your SQL:
DO $$
BEGIN
IF NOT EXISTS(SELECT *
FROM information_schema.triggers
WHERE event_object_table = 'table_name'
AND trigger_name = 'trigger_name'
)
THEN
CREATE TRIGGER trigger_name AFTER INSERT ON table_name FOR EACH ROW EXECUTE PROCEDURE trigger_function();
END IF;
END;
$$