Skip to content

Trigger Operations

Operation: createTrigger

pgm.createTrigger( table_name, trigger_name, trigger_options )

IMPORTANT

Create a new trigger - postgres docs

Arguments

NameTypeDescription
table_nameNameName of the table where the new trigger will live
trigger_namestringName of the new trigger
trigger_optionsobjectCheck below for available options
definitionstringOptional definition of function which will be created with same name as trigger

Trigger Options:

OptionTypeDescription
whenstringBEFORE, AFTER, or INSTEAD OF
operationstring or array[string]INSERT, UPDATE[ OF ...], DELETE or TRUNCATE
constraintbooleanCreates constraint trigger
functionNameThe name of procedure to execute
functionParamsarrayParameters of the procedure
levelstringSTATEMENT, or ROW
conditionstringCondition to met to execute trigger
deferrablebooleanFlag for deferrable constraint trigger
deferredbooleanFlag for initially deferred deferrable constraint trigger

Reverse Operation: dropTrigger

pgm.dropTrigger( table_name, trigger_name, drop_options )

IMPORTANT

Drop a trigger - postgres docs

Arguments

NameTypeDescription
table_nameNameName of the table where the trigger lives
trigger_namestringName of the trigger to drop
drop_optionsobjectCheck below for available options

Drop Options:

OptionTypeDescription
ifExistsbooleanDrops trigger only if it exists
cascadebooleanDrops also dependent objects

Operation: renameTrigger

pgm.renameTrigger( table_name, old_trigger_name, new_trigger_name )

IMPORTANT

Rename a trigger - postgres docs

Arguments

NameTypeDescription
table_nameNameName of the table where the trigger lives
old_trigger_namestringOld name of the trigger
new_trigger_namestringNew name of the trigger