-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Labels
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
Reactions are currently unavailable