Search code examples
postgresqltypeorm

Is there a way to disable triggers globally in Postgresql?


I have db migrations on TypeOrm for Postgresql. Some of them updates some tables, some tables have some triggers already. I just want to make sure that trigger system is disabled at the very beginning of the migrations.

I know it's possible to disable triggers on a specific table. What I need if to disable/enable db triggers globally on a Postgresql database, not for a specific table.

Would it be possible?


Solution

  • No.

    You can only enable/disable at the table level.

    Your only approximation to a "command" that does it would be to write a script/stored proc that queries pg_trigger to find tables that have triggers and executes

    ALTER TABLE <table_name> DISABLE TRIGGER ALL
    

    And similar to enable them.