MishkaBlog.Resources.Mixins.PaperTrailMixin (Mishka Blog v0.0.1)

Copy Markdown View Source

The version resource a PaperTrail-tracked blog resource keeps its history in: the table, its foreign key to the record, and the actions and policies that read the history.

paper_trail do
  mixin {MishkaBlog.Resources.Mixins.PaperTrailMixin, :postgres, ["mishka_blog_tag_versions"]}
end

The versions are global rather than per site, so a record's history can be read across sites by a master. The foreign key cascades, so deleting the record deletes its versions.

The version resource gets these read actions, all bypassing the tenant:

  • :get_any - One version by id.
  • :read_any - Every version.
  • :sorted_versions - Every version, newest first, paginated.

A version holds a full copy of its record, drafts included, so it is for an admin however it is reached, the record's own history included: a master reads every site's, a site's admin its own site's. A call made with authorize?: false is not checked.

Summary

Functions

The version resource's DSL for table, as quoted code the mixin expands into the resource.

Functions

postgres(table)

@spec postgres(String.t()) :: Macro.t()

The version resource's DSL for table, as quoted code the mixin expands into the resource.