Trigger¶
Defines a trigger on a table
Properties¶
| Property | Type | Required | Description |
|---|---|---|---|
name |
string |
— | The index name. |
sql |
string |
— | User-provided raw SQL snippet. |
when |
BEFORE | AFTER | INSTEAD OF |
— | When to fire the trigger. |
events |
array of (INSERT | UPDATE | DELETE | TRUNCATE) |
— | The events that cause the fire to trigger. |
for_each |
ROW | STATEMENT |
— | For Each Row or Statement. Default: "STATEMENT". |
constraint |
boolean |
— | Create the trigger as a CONSTRAINT TRIGGER (always AFTER and FOR EACH ROW); it may be deferred to the end of the transaction. |
deferrable |
boolean |
— | Whether a constraint trigger's firing can be deferred. |
initially_deferred |
boolean |
— | Whether a deferrable constraint trigger defers by default. |
condition |
string |
— | A Boolean expression that determines whether the trigger function will actually be executed. If WHEN is specified, the function will only be called if the condition returns true. |
function |
string |
— | The trigger function to execute. |
arguments |
array of (boolean | integer | number | string) |
— | An optional comma-separated list of arguments to be provided to the function when the trigger is executed. |
comment |
string |
— | An optional comment about the table. |
dependencies |
dependencies | — | Database objects this object is dependent upon. |
Mutually exclusive forms¶
Exactly one of these must hold:
sqlnameandwhenandeventsandfunction, withoutsql
No other properties are accepted.
Source: schemata/trigger.yml · Resolved JSON Schema: trigger.json