Interface ISnapshotUpgrader
- Namespace
- Excalibur.EventSourcing
- Assembly
- Excalibur.EventSourcing.Abstractions.dll
Defines a contract for upgrading snapshots from older versions to newer versions.
public interface ISnapshotUpgrader
Remarks
Snapshot upgraders are used in event sourcing systems to handle snapshot schema evolution. When a snapshot's schema changes between versions, upgraders transform old snapshot formats to the current version during aggregate hydration from snapshots.
This is the snapshot counterpart to IEventUpgrader, following the same versioning pattern. Register upgraders in DI to enable automatic snapshot migration.
Properties
AggregateType
Gets the aggregate type whose snapshots this upgrader handles.
string AggregateType { get; }
Property Value
- string
The fully-qualified aggregate type name.
FromVersion
Gets the source version this upgrader upgrades from.
int FromVersion { get; }
Property Value
- int
The source snapshot version.
ToVersion
Gets the target version this upgrader upgrades to.
int ToVersion { get; }
Property Value
- int
The target snapshot version.
Methods
CanUpgrade(string, int)
Determines whether this upgrader can upgrade snapshots for the specified aggregate type and version.
bool CanUpgrade(string aggregateType, int fromVersion)
Parameters
aggregateTypestringThe type of the aggregate.
fromVersionintThe snapshot version to upgrade from.
Returns
- bool
True if this upgrader can handle the upgrade, otherwise false.
Upgrade(byte[])
Upgrades a snapshot from an older version to a newer version.
byte[] Upgrade(byte[] oldSnapshotData)
Parameters
oldSnapshotDatabyte[]The old snapshot data.
Returns
- byte[]
The upgraded snapshot data.