Channels: Channel snapshots
Nobody has claimed this yet.
- Dominant language
- Elixir
- Stars
- 296
- Forks
- 86
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 50
Description
User story
We need each ChannelRequest to link to an immutable snapshot of the channel's configuration at the time the request was made, so that historical requests always show the config that was active when they happened.
Details
Implement ChannelSnapshot.get_or_create_current/1 following the existing Workflow Snapshots pattern. A new snapshot is only created when the channel config changes (triggered by a lock_version bump). Many requests reference the same snapshot.
Implementation notes
Dependencies: #4399 (schema), #4405 (observer creates requests that reference snapshots)
Key technical considerations:
- Race condition on concurrent requests after config change: use
ON CONFLICT DO NOTHING+ re-read pattern to avoid crashing on the unique index[:channel_id, :lock_version] - Snapshot denormalises credential names from
ProjectCredential → Credentialso they survive credential renames/deletions - Snapshots are immutable after creation (
timestamps(updated_at: false))
Release notes
N/A — internal data integrity mechanism, not directly user-facing.
User acceptance criteria
-
get_or_create_current/1returns existing snapshot if one exists for the channel's currentlock_version, or creates a new one - Race condition handled: concurrent requests after config change don't crash on unique index violation (
ON CONFLICT DO NOTHING+ re-read) - Snapshot captures:
name,sink_url, credential IDs + denormalised credential names,enabled,lock_version - New snapshot created when channel config changes (triggered by
lock_versionbump) -
ChannelRequestrecords referencechannel_snapshot_id - Snapshots are immutable after creation
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the existing Workflow Snapshots pattern and the schema work in #4399, then inspect how the observer from #4405 creates ChannelRequest records. Done means current-version snapshots are reused or safely created under concurrency, capture the listed channel and credential data immutably, and are referenced by ChannelRequest records.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- elixir
- Domain
- backend, databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100