Skip to content

Latest commit

 

History

History
49 lines (34 loc) · 2.12 KB

triggers.md

File metadata and controls

49 lines (34 loc) · 2.12 KB

Trigger Operations

pgm.createTrigger( table_name, trigger_name, trigger_options )

Create a new trigger - postgres docs

Arguments:

  • table_name [Name] - name of the table where the new trigger will live
  • trigger_name [Name] - name of the new trigger
  • trigger_options [object] - options:
    • when [string] - BEFORE, AFTER, or INSTEAD OF
    • operation [string or array of strings] - INSERT, UPDATE[ OF ...], DELETE or TRUNCATE
    • constraint [boolean] - creates constraint trigger
    • function [Name] - the name of procedure to execute
    • functionArgs [array] - parameters of the procedure
    • level [string] - STATEMENT, or ROW
    • condition [string] - condition to met to execute trigger
    • deferrable [boolean] - flag for deferrable constraint trigger
    • deferred [boolean] - flag for initially deferred deferrable constraint trigger
  • definition [string] - optional definition of function which will be created with same name as trigger

Reverse Operation: dropTrigger


pgm.dropTrigger( table_name, trigger_name, drop_options )

Drop a trigger - postgres docs

Arguments:

  • table_name [Name] - name of the table where the trigger lives
  • trigger_name [Name] - name of the trigger to drop
  • drop_options [object] - options:
    • ifExists [boolean] - drops trigger only if it exists
    • cascade [boolean] - drops also dependent objects

pgm.renameTrigger( table_name, old_trigger_name, new_trigger_name )

Rename a trigger - postgres docs

Arguments:

  • table_name [Name] - name of the table where the trigger lives
  • old_trigger_name [Name] - old name of the trigger
  • new_trigger_name [Name] - new name of the trigger