When generating migration SQL, pgschema produces triggers in the following canonical format:
Copy
CREATE OR REPLACE TRIGGER trigger_name { BEFORE | AFTER | INSTEAD OF } { INSERT | UPDATE | DELETE | TRUNCATE } [ OR ... ] ON [schema.]table_name FOR EACH { ROW | STATEMENT } [ WHEN (condition) ] EXECUTE FUNCTION function_name();
Key characteristics of the canonical format:
Always uses CREATE OR REPLACE TRIGGER for modifications
Events are ordered consistently: INSERT, UPDATE, DELETE, TRUNCATE
Multi-line formatting with proper indentation for readability
Explicit FOR EACH clause (ROW is default if not specified)
WHEN conditions are properly parenthesized
Function names include parentheses even when no arguments
Schema qualifiers only included when table is in different schema than target
For DROP operations: DROP TRIGGER IF EXISTS trigger_name ON table_name;