Transaction annotations are JSON objects that you attach to a transaction. Any changes that occur within that transaction following the annotation statement will include the annotations in their metadata.To set annotations:
Annotations must be set within the transaction they’re annotating, before changes are made:
Copy
Ask AI
begin; -- Set annotations for this transaction select pg_logical_emit_message(true, 'sequin:transaction_annotations.set', '{ "username": "paul.atreides", "source": "web_ui", "request_id": "req_123" }'); -- All changes in this transaction will include the annotations insert into orders (customer_id, product, quantity) values (789, 'Wireless Headphones', 1); update customers set last_order_at = now() where id = 789;commit;
Annotations are automatically cleared at the end of each transaction. You can also explicitly clear them, ensuring they will not be included in any changes following the clear statement: