ash_versioned Changelog
Copy Markdown
v0.2.0 / 2026-10-13
Adds relationship declarations pointing to versioned resources and renames generated internal actions.
Breaking Changes
The generated internal actions used by every versioned update have been renamed
version_mark_stale→__ash_versioned_mark_stale__andversion_reinsert→__ash_versioned_reinsert__.Notifiers, PubSub
publishentries, validations (action_is/1), or policies referring to the old names must be updated.Every versioned resource now defines a reserved
__ash_versioned_latest__calculation and a__ash_versioned_read__read action.When
AshVersioned.Relationshipsis added to a resource, athroughpath with a plain relationship to a versioned resource is a compile error. Replace such relationships with their*_versionedequivalents.
Features
AshVersioned.Relationshipsaddsbelongs_to_versioned,has_one_versioned, andhas_many_versionedto therelationshipssection, for relationships to versioned resources from any resource.AshVersioned.Resourceincludes it automatically; non-versioned resources list it inextensions.- Each takes the same options as its Ash equivalent.
- The latest version of the destination is resolved in loads, aggregates,
exists, and filters or sorts through the relationship. - Relationships to archived records still resolve. Add a relationship
filterto exclude them. belongs_to_versionedjoins on the destination's identity attribute (:resource_idby default, or the resource's own identity for self-references) and never creates a foreign key.has_one_versionedandhas_many_versionedsupportthroughpaths, resolving the latest version of each record reached by the path.- Self-referential and mutually referential relationships are supported with destinations verified after compilation.
Many-to-many relationships are not currently supported but are on the roadmap.
belongs_to_actorrelationships to a versioned resource now use the same underlying functionality asbelongs_to_versioned.
Bug Fixes
__ash_versioned_reinsert__is no longer authorized separately. A versioned update (mark the current version stale, insert the new version) is a single operation, authorized once as the user's update or destroy action.Previously, the reinsert was checked against the resource's policies as a create action, so an actor allowed to update but not to create would be forbidden partway through an update. Policies written only to permit
version_reinsertare no longer needed.__ash_versioned_reinsert__called directly is still subject to policies.A self-referential
belongs_to_actorresolves its configuration from the resource's own DSL.A
postgres.referencesentry declared for abelongs_to_actorrelationship to a versioned resource is no longer accompanied by a second, generatedignore?: truereference for the same relationship.
Migrations
No database changes are required for existing versioned resources: the new calculation and read action, and the renamed actions, don't affect the schema.
v0.1.0 / 2026-10-02
Initial release. Implements SCD2 (slowly-changing-dimension type 2) versioning for Ash resources: every mutation appends a new row instead of updating in place, so no historical value is ever overwritten.