Reference
Transaction Annotations
Reference for Sequin transaction annotations
Transaction annotations allow you to attach metadata to database changes. When you set annotations, all change messages following the annotation will include the annotations in their metadata.
Protocol
Set annotations inside a transaction using the function pg_logical_emit_message
:
Message prefixes
Prefix | Description |
---|---|
sequin:transaction_annotations.set | Sets annotations for all following changes in the current transaction |
sequin:transaction_annotations.clear | Clears annotations for all following changes in the current transaction |
Behavior
Scope
- Annotations are transaction-scoped
- They apply to all changes following the annotation within the transaction
- Setting new annotations overwrites previous annotations in the same transaction
Limitations
- Must be valid JSON
- Cannot be set outside a transaction
- Annotations are only supported for change messages. They are not supported for row messages.
Message format
Annotations appear in the metadata.transaction_annotations
field of change messages:
If no annotations are set, the field will be null
.
Examples
Setting annotations
Clearing annotations
Overwriting annotations
Related
Was this page helpful?