Skip to content

Include custom carbonite prefix in remaining multi step names#148

Merged
maltoe merged 2 commits intobitcrowd:mainfrom
Hedde:fix-multi-step-name-prefix
Apr 19, 2026
Merged

Include custom carbonite prefix in remaining multi step names#148
maltoe merged 2 commits intobitcrowd:mainfrom
Hedde:fix-multi-step-name-prefix

Conversation

@Hedde
Copy link
Copy Markdown
Contributor

@Hedde Hedde commented Apr 16, 2026

Follows up on #143closes #147.

Extends the prefixed step-name behaviour introduced in #143 to the remaining
Carbonite.Multi functions: fetch_changes/2 and override_mode/2 now also
include the :carbonite_prefix option in their multi step name. Without this,
combining these functions with different prefixes in one Ecto.Multi raises
because of a duplicate step name.

Multi.new()
|> Carbonite.Multi.insert_transaction(%{type: "foo"})
|> Carbonite.Multi.fetch_changes()
|> Carbonite.Multi.insert_transaction(%{type: "foo"}, carbonite_prefix: "my_other_audits")
|> Carbonite.Multi.fetch_changes(carbonite_prefix: "my_other_audits")

Changes:

  • fetch_changes/2 step is {:carbonite_changes, <prefix>} when :carbonite_prefix is given
  • override_mode/2 step is {:carbonite_triggers, <prefix>} when :carbonite_prefix is given
  • Matching "operation names include the given prefix option" tests
  • CHANGELOG entry under Unreleased

This patch extends the behaviour introduced in bitcrowd#143 to the remaining
`Carbonite.Multi` functions: `fetch_changes/2` and `override_mode/2` now
also include the `:carbonite_prefix` option in their multi step name.

Without this, calls to these functions for different prefixes within
the same `Ecto.Multi` raise because of a duplicate step name, which
defeats the multi-stream setups that bitcrowd#143 was meant to enable, e.g.

```
Multi.new()
|> Carbonite.Multi.insert_transaction(%{type: "foo"})
|> Carbonite.Multi.fetch_changes()
|> Carbonite.Multi.insert_transaction(%{type: "foo"}, carbonite_prefix: "my_other_audits")
|> Carbonite.Multi.fetch_changes(carbonite_prefix: "my_other_audits")
```
Copy link
Copy Markdown
Collaborator

@maltoe maltoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 💜

Comment thread CHANGELOG.md Outdated
@maltoe maltoe enabled auto-merge (squash) April 17, 2026 11:53
@maltoe maltoe merged commit cb3315b into bitcrowd:main Apr 19, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multi.fetch_changes/2 and Multi.override_mode/2 don't include prefix in multi step name

2 participants