From 5607376183455884d871311cbfcf60c5a6bd635b Mon Sep 17 00:00:00 2001 From: Izel Nakri Date: Tue, 14 Mar 2017 18:42:09 +0100 Subject: [PATCH] v0.6.2 release small adjustments --- CHANGELOG.md | 5 +++-- NOTES.md | 1 + README.md | 8 ++++---- doc/404.html | 4 ++-- doc/Mix.Tasks.Papertrail.Install.html | 6 +++--- doc/PaperTrail.Migration.html | 6 +++--- doc/PaperTrail.RepoClient.html | 6 +++--- doc/PaperTrail.Version.html | 6 +++--- doc/PaperTrail.VersionQueries.html | 6 +++--- doc/PaperTrail.html | 6 +++--- doc/api-reference.html | 6 +++--- doc/index.html | 2 +- lib/mix/tasks/papertrail/install.ex | 9 +-------- lib/version.ex | 2 +- mix.exs | 2 +- 15 files changed, 35 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 037bc0d0..77a585a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,2 +1,3 @@ -- Version event names now match their Ecto counterparts. Version event names are now 'insert', 'update', 'delete' instead of 'create', 'update', 'destroy'. -- Introduction of strict mode. Please read the documentation for more information on the required set_by field and foreign-key references. +v0.6.0 - March 14th: +- Version event names are now 'insert', 'update', 'delete' to match their Ecto counterpats instead of 'create', 'update', 'destroy'. +- Introduction of strict mode. Please read the documentation for more information on the required origin and originator_id field and foreign-key references. diff --git a/NOTES.md b/NOTES.md index dd1a9f0a..8d29bee2 100644 --- a/NOTES.md +++ b/NOTES.md @@ -1,3 +1,4 @@ - add setter_id foreign-key column, PaperTrail.insert_all, insert! and friends - if I ever do the merging logic keep it in mind that updated_at of the record must be sourced from the inserted_at of the version/ +** add PaperTrail.insert!, PaperTrail.update!, PaperTrail.delete! # it shouldnt return a version, it shouldnt give errors/raise?(optional?) diff --git a/README.md b/README.md index c45add66..ae4cd8a4 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ PaperTrail lets you record every change in your database in a separate database table called ```versions```. Library generates a new version record with associated data every time you run ```PaperTrail.insert/1```, ```PaperTrail.update/1``` or ```PaperTrail.delete/1``` functions. Simply these functions wrap your Repo insert, update or destroy actions in a database transaction, so if your database action fails you won't get a new version. -PaperTrail is assailed with hundreds of test assertions for each release. Data integrity is an important purpose of this project, please refer to the strict_mode if you want to ensure data correctness and integrity of your versions. For simpler use cases the default mode of PaperTrail should suffice. +PaperTrail is assailed with hundreds of test assertions for each release. Data integrity is an important aim of this project, please refer to the strict_mode if you want to ensure data correctness and integrity of your versions. For simpler use cases the default mode of PaperTrail should suffice. ## Example @@ -201,8 +201,8 @@ defmodule Repo.Migrations.AddVersions do timestamps() end - create index(:companies, [:first_version_id]) - create index(:companies, [:current_version_id]) + create unique_index(:companies, [:first_version_id]) + create unique_index(:companies, [:current_version_id]) end end @@ -256,7 +256,7 @@ edited_company = Company.changeset(company, %{name: "Acme Inc."}) |> PaperTrail. # item_changes: %{name: "Acme Inc."}, originator_id: nil, origin: "documentation", meta: nil}}} ``` -If the version ```origin``` field isn't provided with a value, default ```origin``` will be "unknown". Origin column has a null constraint on strict_mode by design, you should put an ```origin``` reference to describe who makes the change. This is important for big applications because a model can change from many sources. +Additionally, you can put a null constraint on ```origin``` column, you should always put an ```origin``` reference to describe who makes the change. This is important for big applications because a model can change from many sources. ### Storing version meta data You might want to add some meta data that doesn't belong to ``originator_id`` and ``origin`` fields. Such data could be stored in one object named ```meta``` in paper_trail versions. Meta field could be passed as the second optional parameter to PaperTrail.insert\\2, PaperTrail.update\\2, PaperTrail.delete\\2 functions: diff --git a/doc/404.html b/doc/404.html index 0a7e1d37..cf9cd57c 100644 --- a/doc/404.html +++ b/doc/404.html @@ -5,7 +5,7 @@ - 404 – paper_trail v0.6.1 + 404 – paper_trail v0.6.2 @@ -28,7 +28,7 @@

paper_trail

diff --git a/doc/Mix.Tasks.Papertrail.Install.html b/doc/Mix.Tasks.Papertrail.Install.html index cdc1ea61..6530874c 100644 --- a/doc/Mix.Tasks.Papertrail.Install.html +++ b/doc/Mix.Tasks.Papertrail.Install.html @@ -5,7 +5,7 @@ - Mix.Tasks.Papertrail.Install – paper_trail v0.6.1 + Mix.Tasks.Papertrail.Install – paper_trail v0.6.2 @@ -28,7 +28,7 @@

paper_trail

@@ -60,7 +60,7 @@

- paper_trail v0.6.1 + paper_trail v0.6.2 Mix.Tasks.Papertrail.Install diff --git a/doc/PaperTrail.Migration.html b/doc/PaperTrail.Migration.html index 6f1ed596..ee2026c1 100644 --- a/doc/PaperTrail.Migration.html +++ b/doc/PaperTrail.Migration.html @@ -5,7 +5,7 @@ - PaperTrail.Migration – paper_trail v0.6.1 + PaperTrail.Migration – paper_trail v0.6.2 @@ -28,7 +28,7 @@

paper_trail

@@ -60,7 +60,7 @@

- paper_trail v0.6.1 + paper_trail v0.6.2 PaperTrail.Migration diff --git a/doc/PaperTrail.RepoClient.html b/doc/PaperTrail.RepoClient.html index 1ebab9c4..83dd85b9 100644 --- a/doc/PaperTrail.RepoClient.html +++ b/doc/PaperTrail.RepoClient.html @@ -5,7 +5,7 @@ - PaperTrail.RepoClient – paper_trail v0.6.1 + PaperTrail.RepoClient – paper_trail v0.6.2 @@ -28,7 +28,7 @@

paper_trail

@@ -60,7 +60,7 @@

- paper_trail v0.6.1 + paper_trail v0.6.2 PaperTrail.RepoClient diff --git a/doc/PaperTrail.Version.html b/doc/PaperTrail.Version.html index ced56882..1fb6468d 100644 --- a/doc/PaperTrail.Version.html +++ b/doc/PaperTrail.Version.html @@ -5,7 +5,7 @@ - PaperTrail.Version – paper_trail v0.6.1 + PaperTrail.Version – paper_trail v0.6.2 @@ -28,7 +28,7 @@

paper_trail

@@ -60,7 +60,7 @@

- paper_trail v0.6.1 + paper_trail v0.6.2 PaperTrail.Version diff --git a/doc/PaperTrail.VersionQueries.html b/doc/PaperTrail.VersionQueries.html index 63b4d540..8455ef9f 100644 --- a/doc/PaperTrail.VersionQueries.html +++ b/doc/PaperTrail.VersionQueries.html @@ -5,7 +5,7 @@ - PaperTrail.VersionQueries – paper_trail v0.6.1 + PaperTrail.VersionQueries – paper_trail v0.6.2 @@ -28,7 +28,7 @@

paper_trail

@@ -60,7 +60,7 @@

- paper_trail v0.6.1 + paper_trail v0.6.2 PaperTrail.VersionQueries diff --git a/doc/PaperTrail.html b/doc/PaperTrail.html index 9e378477..3b51a0aa 100644 --- a/doc/PaperTrail.html +++ b/doc/PaperTrail.html @@ -5,7 +5,7 @@ - PaperTrail – paper_trail v0.6.1 + PaperTrail – paper_trail v0.6.2 @@ -28,7 +28,7 @@

paper_trail

@@ -60,7 +60,7 @@

- paper_trail v0.6.1 + paper_trail v0.6.2 PaperTrail diff --git a/doc/api-reference.html b/doc/api-reference.html index 3402b08d..e528d65e 100644 --- a/doc/api-reference.html +++ b/doc/api-reference.html @@ -5,7 +5,7 @@ - API Reference – paper_trail v0.6.1 + API Reference – paper_trail v0.6.2 @@ -28,7 +28,7 @@

paper_trail

@@ -60,7 +60,7 @@

- paper_trail v0.6.1 + paper_trail v0.6.2 API Reference

diff --git a/doc/index.html b/doc/index.html index 3d2f9962..0aad5829 100644 --- a/doc/index.html +++ b/doc/index.html @@ -2,7 +2,7 @@ - paper_trail v0.6.1 – Documentation + paper_trail v0.6.2 – Documentation diff --git a/lib/mix/tasks/papertrail/install.ex b/lib/mix/tasks/papertrail/install.ex index c318137b..8b7a2691 100644 --- a/lib/mix/tasks/papertrail/install.ex +++ b/lib/mix/tasks/papertrail/install.ex @@ -22,7 +22,7 @@ defmodule Mix.Tasks.Papertrail.Install do add :item_id, :integer add :item_changes, :map, null: false add :originator_id, references(:users) # you can change :users to your own foreign key constraint - #{origin_by_field()} + add :origin, :string, size: 50 add :meta, :map add :inserted_at, :utc_datetime, null: false @@ -38,13 +38,6 @@ defmodule Mix.Tasks.Papertrail.Install do """ end - defp origin_by_field do - case PaperTrail.RepoClient.strict_mode() do - true -> "add :origin, :string, size: 50, null: false, default: \"unknown\"" - _ -> "add :origin, :string, size: 50" - end - end - defp timestamp do {{y, m, d}, {hh, mm, ss}} = :calendar.universal_time() "#{y}#{pad(m)}#{pad(d)}#{pad(hh)}#{pad(mm)}#{pad(ss)}" diff --git a/lib/version.ex b/lib/version.ex index 28724644..4788419b 100644 --- a/lib/version.ex +++ b/lib/version.ex @@ -29,6 +29,6 @@ defmodule PaperTrail.Version do end def count do - from(version in __MODULE__, select: count(version.id)) |> PaperTrail.RepoClient.repo.all + from(version in __MODULE__, select: count(version.id)) |> PaperTrail.RepoClient.repo.one end end diff --git a/mix.exs b/mix.exs index 2e2e764b..16aaaa7a 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule PaperTrail.Mixfile do def project do [ app: :paper_trail, - version: "0.6.1", + version: "0.6.2", elixir: "~> 1.4", description: description(), build_embedded: Mix.env == :prod,