Skip to content

Commit

Permalink
v0.6.2 release small adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
izelnakri committed Mar 14, 2017
1 parent 066f287 commit 5607376
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 40 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions NOTES.md
Original file line number Diff line number Diff line change
@@ -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?)
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions doc/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.14.5">
<title>404 – paper_trail v0.6.1</title>
<title>404 – paper_trail v0.6.2</title>
<link rel="stylesheet" href="dist/app-a07cea761b.css" />

<link rel="canonical" href="https://hexdocs.pm/paper_trail/404.html" />
Expand All @@ -28,7 +28,7 @@ <h1 class="sidebar-projectName">
paper_trail
</h1>
<h2 class="sidebar-projectVersion">
v0.6.1
v0.6.2
</h2>
</div>

Expand Down
6 changes: 3 additions & 3 deletions doc/Mix.Tasks.Papertrail.Install.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.14.5">
<title>Mix.Tasks.Papertrail.Install – paper_trail v0.6.1</title>
<title>Mix.Tasks.Papertrail.Install – paper_trail v0.6.2</title>
<link rel="stylesheet" href="dist/app-a07cea761b.css" />

<link rel="canonical" href="https://hexdocs.pm/paper_trail/Mix.Tasks.Papertrail.Install.html" />
Expand All @@ -28,7 +28,7 @@ <h1 class="sidebar-projectName">
paper_trail
</h1>
<h2 class="sidebar-projectVersion">
v0.6.1
v0.6.2
</h2>
</div>

Expand Down Expand Up @@ -60,7 +60,7 @@ <h2 class="sidebar-projectVersion">


<h1>
<small class="visible-xs">paper_trail v0.6.1</small>
<small class="visible-xs">paper_trail v0.6.2</small>
Mix.Tasks.Papertrail.Install


Expand Down
6 changes: 3 additions & 3 deletions doc/PaperTrail.Migration.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.14.5">
<title>PaperTrail.Migration – paper_trail v0.6.1</title>
<title>PaperTrail.Migration – paper_trail v0.6.2</title>
<link rel="stylesheet" href="dist/app-a07cea761b.css" />

<link rel="canonical" href="https://hexdocs.pm/paper_trail/PaperTrail.Migration.html" />
Expand All @@ -28,7 +28,7 @@ <h1 class="sidebar-projectName">
paper_trail
</h1>
<h2 class="sidebar-projectVersion">
v0.6.1
v0.6.2
</h2>
</div>

Expand Down Expand Up @@ -60,7 +60,7 @@ <h2 class="sidebar-projectVersion">


<h1>
<small class="visible-xs">paper_trail v0.6.1</small>
<small class="visible-xs">paper_trail v0.6.2</small>
PaperTrail.Migration


Expand Down
6 changes: 3 additions & 3 deletions doc/PaperTrail.RepoClient.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.14.5">
<title>PaperTrail.RepoClient – paper_trail v0.6.1</title>
<title>PaperTrail.RepoClient – paper_trail v0.6.2</title>
<link rel="stylesheet" href="dist/app-a07cea761b.css" />

<link rel="canonical" href="https://hexdocs.pm/paper_trail/PaperTrail.RepoClient.html" />
Expand All @@ -28,7 +28,7 @@ <h1 class="sidebar-projectName">
paper_trail
</h1>
<h2 class="sidebar-projectVersion">
v0.6.1
v0.6.2
</h2>
</div>

Expand Down Expand Up @@ -60,7 +60,7 @@ <h2 class="sidebar-projectVersion">


<h1>
<small class="visible-xs">paper_trail v0.6.1</small>
<small class="visible-xs">paper_trail v0.6.2</small>
PaperTrail.RepoClient


Expand Down
6 changes: 3 additions & 3 deletions doc/PaperTrail.Version.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.14.5">
<title>PaperTrail.Version – paper_trail v0.6.1</title>
<title>PaperTrail.Version – paper_trail v0.6.2</title>
<link rel="stylesheet" href="dist/app-a07cea761b.css" />

<link rel="canonical" href="https://hexdocs.pm/paper_trail/PaperTrail.Version.html" />
Expand All @@ -28,7 +28,7 @@ <h1 class="sidebar-projectName">
paper_trail
</h1>
<h2 class="sidebar-projectVersion">
v0.6.1
v0.6.2
</h2>
</div>

Expand Down Expand Up @@ -60,7 +60,7 @@ <h2 class="sidebar-projectVersion">


<h1>
<small class="visible-xs">paper_trail v0.6.1</small>
<small class="visible-xs">paper_trail v0.6.2</small>
PaperTrail.Version


Expand Down
6 changes: 3 additions & 3 deletions doc/PaperTrail.VersionQueries.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.14.5">
<title>PaperTrail.VersionQueries – paper_trail v0.6.1</title>
<title>PaperTrail.VersionQueries – paper_trail v0.6.2</title>
<link rel="stylesheet" href="dist/app-a07cea761b.css" />

<link rel="canonical" href="https://hexdocs.pm/paper_trail/PaperTrail.VersionQueries.html" />
Expand All @@ -28,7 +28,7 @@ <h1 class="sidebar-projectName">
paper_trail
</h1>
<h2 class="sidebar-projectVersion">
v0.6.1
v0.6.2
</h2>
</div>

Expand Down Expand Up @@ -60,7 +60,7 @@ <h2 class="sidebar-projectVersion">


<h1>
<small class="visible-xs">paper_trail v0.6.1</small>
<small class="visible-xs">paper_trail v0.6.2</small>
PaperTrail.VersionQueries


Expand Down
6 changes: 3 additions & 3 deletions doc/PaperTrail.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.14.5">
<title>PaperTrail – paper_trail v0.6.1</title>
<title>PaperTrail – paper_trail v0.6.2</title>
<link rel="stylesheet" href="dist/app-a07cea761b.css" />

<link rel="canonical" href="https://hexdocs.pm/paper_trail/PaperTrail.html" />
Expand All @@ -28,7 +28,7 @@ <h1 class="sidebar-projectName">
paper_trail
</h1>
<h2 class="sidebar-projectVersion">
v0.6.1
v0.6.2
</h2>
</div>

Expand Down Expand Up @@ -60,7 +60,7 @@ <h2 class="sidebar-projectVersion">


<h1>
<small class="visible-xs">paper_trail v0.6.1</small>
<small class="visible-xs">paper_trail v0.6.2</small>
PaperTrail


Expand Down
6 changes: 3 additions & 3 deletions doc/api-reference.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.14.5">
<title>API Reference – paper_trail v0.6.1</title>
<title>API Reference – paper_trail v0.6.2</title>
<link rel="stylesheet" href="dist/app-a07cea761b.css" />

<link rel="canonical" href="https://hexdocs.pm/paper_trail/api-reference.html" />
Expand All @@ -28,7 +28,7 @@ <h1 class="sidebar-projectName">
paper_trail
</h1>
<h2 class="sidebar-projectVersion">
v0.6.1
v0.6.2
</h2>
</div>

Expand Down Expand Up @@ -60,7 +60,7 @@ <h2 class="sidebar-projectVersion">


<h1>
<small class="visible-xs">paper_trail v0.6.1</small>
<small class="visible-xs">paper_trail v0.6.2</small>
API Reference
</h1>

Expand Down
2 changes: 1 addition & 1 deletion doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>paper_trail v0.6.1 – Documentation</title>
<title>paper_trail v0.6.2 – Documentation</title>
<meta http-equiv="refresh" content="0; url=api-reference.html">
<meta name="robots" content="noindex">
<meta name="generator" content="ExDoc v0.14.5">
Expand Down
9 changes: 1 addition & 8 deletions lib/mix/tasks/papertrail/install.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)}"
Expand Down
2 changes: 1 addition & 1 deletion lib/version.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 5607376

Please sign in to comment.