Skip to content

Metadata

André Diego Piske edited this page Feb 24, 2025 · 4 revisions

The irontrail_changes table has a column named metadata of type JSONB which can store any sort of data.

Metadata on the Ruby side is stored in IronTrail::Current#metadata hashmap and it's serialized to JSON before being sent to Postgres.

You can use any key name you like, but a few names are processed in a special way by IronTrail, see the Special keys section down below. Also, avoid using key names prefixed by an underscore (_).

Special keys

These are all metadata key names that have special meaning to IronTrail:

  • _actor_type
  • _actor_id
  • _db_created_at

The _actor_type and _actor_id, when populated, will be moved from the metadata column into their own columns in the irontrail_changes, which are the actor_type and actor_id column.

The _db_created_at key will be populated in case the change record creation date was determined by the trigger function. Read more about created_at in change record.

Sidekiq middleware

If you're using Sidekiq, you may want to use the IronTrail::SidekiqMiddleware. When enabled, it will automatically inject metadata about the sidekiq job being run.

The injected keys are:

  • job.jid Sidekiq's Job ID
  • job.class The job class name
  • job.queue The sidekiq queue name
  • job.bid The sidekiq batch ID. This is only present when the job runs in a batch

Clone this wiki locally