(schema: string, table: string)
| 240 | } |
| 241 | |
| 242 | export function createNotifyTrigger(schema: string, table: string): string { |
| 243 | const triggerName = hashName(schema, 'notify_trigger', table); |
| 244 | const channelName = hashName(schema, 'notify_channel', table); |
| 245 | return ` |
| 246 | DO $$ |
| 247 | BEGIN |
| 248 | CREATE TRIGGER "${triggerName}" AFTER INSERT OR UPDATE OR DELETE |
| 249 | ON "${schema}"."${table}" |
| 250 | FOR EACH ROW EXECUTE FUNCTION "${schema}".send_notification('${channelName}'); |
| 251 | EXCEPTION |
| 252 | WHEN duplicate_object THEN |
| 253 | RAISE NOTICE 'Trigger already exists. Ignoring...'; |
| 254 | END$$; |
| 255 | `; |
| 256 | } |
| 257 | |
| 258 | function dropTrigger(schema: string, table: string, triggerName: string): string { |
| 259 | return `DROP TRIGGER IF EXISTS "${triggerName}" |
no test coverage detected