Enable or disable triggers

Enable or disable triggers
Output of running the SQL "SELECT * FROM pg_trigger WHERE tgname;"

Needed to disable some triggers to allow a deployment script to run, it was taking a really long time if the triggers were enabled and the core data was not being changed so the triggers were not needed.

DO $$
DECLARE
    t record;    
BEGIN
    FOR t IN
    SELECT trigger_name
    FROM information_schema.triggers
    WHERE trigger_name LIKE '[your trigger name]_%'
    LOOP
        EXECUTE format('ALTER TABLE [your table] DISABLE/ENABLE TRIGGER %I;', t.trigger_name);        
    END LOOP;
END;$$

This will only enable/disable triggers that exist. Originally we were trying to directly enable/disable the triggers but in some situations (TestContainers) they did not exist and would cause a failure in the deployment pipeline.