Verex
This is a simple versioning library for Phoenix. Rather than only versioning changes or
old inactive versions, this library allows for a full history of your modules. Verex does not use an independent
‘versions’ table, but incorporates the full history into the modules existing table. Verex makes use of
a current_flag in the repo to flag an entry as active. It also makes use of a parent_id to allow for simple traversing
of an entries history.
By keeping a full history, Verex allows for associations with other modules on ‘un-active’ records.
Installation
This package is available in Hex, the package can be installed
by adding verex to your list of dependencies in mix.exs:
def deps do
[{:verex, "~> 0.1.0"}]
endConfiguration
Verex makes use of the repo by modifying changesets before making any repo transaction. For this reason, Verex requires the repo of your current project.
In your config.ex file, add your projects repo to the Verex library.
config :verex,
repo: MyProject.RepoMigration
Verex will only work on modules with specific fields. Create a migration to alter the modules’ table and add the following fields:
alter table(:versioned_module) do
add :parent_id, :integer
add :revised_at, :utc_datetime
add :current_flag, :boolean
endYou will also need to add these fields to the modules’ schema:
schema "versioned_modules" do
field :parent_id, :integer
field :revised_at, :utc_datetime
field :current_flag, :boolean
endUsage
Verex works by making changes to a changeset prior to any repo transaction. Therefore rather than
calling Ecto.Repo functions such as Repo.insert, Repo.update, or Repo.delete on your versioned module, call
Verex.Repo.insert,
Verex.Repo.update, and
Verex.Repo.delete
Please look at the documentation for more information on calling these methods.
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/verex.