Thread

  1. Re: [PATCH] Add pg_get_trigger_ddl() to retrieve the CREATE TRIGGER statement

    Marcos Pegoraro <marcos@f10.com.br> — 2025-10-18T20:55:41Z

    Em sáb., 18 de out. de 2025 às 15:23, Philip Alger <paalger0@gmail.com>
    escreveu:
    
    There is no pretty  option for this one, and the intent is for the user to
    be able to input a table and trigger to get the CREATE TRIGGER statement.
    Not sure how drop_first fits in here; we’re not dropping or creating
    triggers.
    
    Sorry, sometimes my fingers don't obey my brain, I wrote one thing thinking
    another.
    In a multi tenant world this feature will be cool for clone or sync ddl of
    two schemas. So, if I’m creating a new schema the way you did works but if
    both exists and I want to update some ddls of a schema, sometimes I have to
    DROP and CREATE or returned command should have CREATE OR REPLACE,
    depending on what ddl you are doing.
    If you try to create a trigger but it already exists, you’ll get an
    exception, so you can emit a DROP IF EXISTS before CREATE of that trigger.
    For this that param drop_first would be.
    I know you are doing only trigger ddl rigth now but I think we would have
    this kind of functions for tables, constraints, triggers, domains and so
    on, then all of them should work the same way, and for this a drop_first or
    if_exists would be good.
    
    Regards
    Marcos
    
    >