diff --git a/example/config/config.exs b/example/config/config.exs index 708ac12d..c88a7f28 100644 --- a/example/config/config.exs +++ b/example/config/config.exs @@ -4,6 +4,12 @@ use Mix.Config config :example, ecto_repos: [Repo] +config :paper_trail, + item_type: Needle.ULID, + originator_type: Needle.ULID +# originator_relationship_options: [references: :id], +# originator: [name: :user, model: Bonfire.Data.Identity.User] + # This configuration is loaded before any dependency and is restricted # to this project. If another project depends on this project, this # file won't be loaded nor affect the parent project. For this reason, diff --git a/example/lib/company.ex b/example/lib/company.ex index 360e9408..f3eb7986 100644 --- a/example/lib/company.ex +++ b/example/lib/company.ex @@ -3,6 +3,7 @@ defmodule Company do import Ecto.Changeset + @primary_key {:id, Ecto.UUID, autogenerate: true} schema "companies" do field :name, :string field :is_active, :boolean diff --git a/example/lib/person.ex b/example/lib/person.ex index 15a8b489..c7374baa 100644 --- a/example/lib/person.ex +++ b/example/lib/person.ex @@ -3,6 +3,7 @@ defmodule Person do import Ecto.Changeset + @primary_key {:id, Ecto.UUID, autogenerate: true} schema "people" do field :first_name, :string field :last_name, :string diff --git a/example/mix.exs b/example/mix.exs index 12953eae..34c5fa75 100644 --- a/example/mix.exs +++ b/example/mix.exs @@ -31,11 +31,17 @@ defmodule Example.Mixfile do # Type "mix help deps" for more examples and options defp deps do [ - {:ecto, "~> 3.0-rc", override: true}, - {:ecto_sql, "~> 3.0-rc", override: true}, - {:postgrex, ">= 0.0.0-rc"}, + {:ecto, "~> 3.12"}, + {:ecto_sql, "~> 3.12"}, + {:postgrex, ">= 0.0.0"}, {:jason, "~> 1.0"}, - {:paper_trail, path: "../"} + {:paper_trail, + #path: "../" + git: "https://github.com/izelnakri/paper_trail" + }, + {:needle_ulid, + git: "https://github.com/bonfire-networks/needle_ulid" + } ] end end diff --git a/example/mix.lock b/example/mix.lock index 9d35df84..491cd2ea 100644 --- a/example/mix.lock +++ b/example/mix.lock @@ -1,13 +1,12 @@ %{ - "connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], []}, - "db_connection": {:hex, :db_connection, "2.0.0-rc.0", "f6960e86b5e524468ec16fb7277e509c784de565ac520213a1813ad2bf7d802f", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm"}, - "decimal": {:hex, :decimal, "1.5.0", "b0433a36d0e2430e3d50291b1c65f53c37d56f83665b43d79963684865beab68", [:mix], [], "hexpm"}, - "ecto": {:hex, :ecto, "3.0.0-rc.1", "c966a270b289739d6895f61bee339065a3075d1df34ddd369d400cf0c936fd6c", [:mix], [{:decimal, "~> 1.5", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}], "hexpm"}, - "ecto_sql": {:hex, :ecto_sql, "3.0.0-rc.0", "a61da743812a47174e8b79dbe6aa7d4a9f7e6dbf8c90cfd7015f3767738b37ba", [:mix], [{:db_connection, "~> 2.0-rc.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.0.0-rc.1", [hex: :ecto, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.9.0-rc.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.14.0-rc.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.2.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"}, - "jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"}, - "paper_trail": {:hex, :paper_trail, "0.7.3", "2e65a18c0928264c2e18dccdba7794b847c90a20cfa3a2fd1e2668d7690452d3", [:mix], [{:ecto, ">= 2.1.0", [hex: :ecto, optional: false]}, {:poison, ">= 3.1.0 or >= 2.0.0", [hex: :poison, optional: false]}, {:postgrex, "~> 0.13.0", [hex: :postgrex, optional: false]}]}, - "poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], []}, - "poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], []}, - "postgrex": {:hex, :postgrex, "0.14.0-rc.1", "a88cbeab25c5f3fc505fc6590bd30877a5acf11b448aedb23b41cbc063824ceb", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.0-rc.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm"}, - "telemetry": {:hex, :telemetry, "0.2.0", "5b40caa3efe4deb30fb12d7cd8ed4f556f6d6bd15c374c2366772161311ce377", [:mix], [], "hexpm"}, + "db_connection": {:hex, :db_connection, "2.7.0", "b99faa9291bb09892c7da373bb82cba59aefa9b36300f6145c5f201c7adf48ec", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "dcf08f31b2701f857dfc787fbad78223d61a32204f217f15e881dd93e4bdd3ff"}, + "decimal": {:hex, :decimal, "2.1.1", "5611dca5d4b2c3dd497dec8f68751f1f1a54755e8ed2a966c2633cf885973ad6", [:mix], [], "hexpm", "53cfe5f497ed0e7771ae1a475575603d77425099ba5faef9394932b35020ffcc"}, + "ecto": {:hex, :ecto, "3.12.3", "1a9111560731f6c3606924c81c870a68a34c819f6d4f03822f370ea31a582208", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "9efd91506ae722f95e48dc49e70d0cb632ede3b7a23896252a60a14ac6d59165"}, + "ecto_sql": {:hex, :ecto_sql, "3.12.0", "73cea17edfa54bde76ee8561b30d29ea08f630959685006d9c6e7d1e59113b7d", [:mix], [{:db_connection, "~> 2.4.1 or ~> 2.5", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.12", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.7", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.19 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1 or ~> 2.2", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "dc9e4d206f274f3947e96142a8fdc5f69a2a6a9abb4649ef5c882323b6d512f0"}, + "ex_ulid": {:hex, :ex_ulid, "0.1.0", "e6e717c57344f6e500d0190ccb4edc862b985a3680f15834af992ec065d4dcff", [:mix], [], "hexpm", "a2befd477aebc4639563de7e233e175cacf8a8f42c8f6778c88d60c13bf20860"}, + "jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"}, + "needle_ulid": {:git, "https://github.com/bonfire-networks/needle_ulid", "10f9ad7c9916f9ff3d5e4f34a1a270c45056fe8d", []}, + "paper_trail": {:git, "https://github.com/izelnakri/paper_trail", "5aae29eabe62706739ba035c89bcf82f457fe27d", []}, + "postgrex": {:hex, :postgrex, "0.19.1", "73b498508b69aded53907fe48a1fee811be34cc720e69ef4ccd568c8715495ea", [:mix], [{:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "8bac7885a18f381e091ec6caf41bda7bb8c77912bb0e9285212829afe5d8a8f8"}, + "telemetry": {:hex, :telemetry, "1.3.0", "fedebbae410d715cf8e7062c96a1ef32ec22e764197f70cda73d82778d61e7a2", [:rebar3], [], "hexpm", "7015fc8919dbe63764f4b4b87a95b7c0996bd539e0d499be6ec9d7f3875b79e6"}, } diff --git a/example/priv/repo/migrations/20160715113439_create_companies.exs b/example/priv/repo/migrations/20160715113439_create_companies.exs index 37fe63ea..f8ba3cf9 100644 --- a/example/priv/repo/migrations/20160715113439_create_companies.exs +++ b/example/priv/repo/migrations/20160715113439_create_companies.exs @@ -2,7 +2,8 @@ defmodule Example.Repo.Migrations.CreateCompanies do use Ecto.Migration def change do - create table(:companies) do + create table(:companies, primary_key: false) do + add :id, :uuid, primary_key: true, null: false add :name, :string add :is_active, :boolean add :website, :string diff --git a/example/priv/repo/migrations/20160715113442_create_people.exs b/example/priv/repo/migrations/20160715113442_create_people.exs index 30e2262d..f3d48b50 100644 --- a/example/priv/repo/migrations/20160715113442_create_people.exs +++ b/example/priv/repo/migrations/20160715113442_create_people.exs @@ -2,7 +2,8 @@ defmodule Example.Repo.Migrations.CreatePeople do use Ecto.Migration def change do - create table(:people) do + create table(:people, primary_key: false) do + add :id, :uuid, primary_key: true, null: false add :first_name, :string add :last_name, :string add :visit_count, :integer diff --git a/example/priv/repo/migrations/20160715134921_add_versions.exs b/example/priv/repo/migrations/20160715134921_add_versions.exs index 085b640f..3d22b4e9 100644 --- a/example/priv/repo/migrations/20160715134921_add_versions.exs +++ b/example/priv/repo/migrations/20160715134921_add_versions.exs @@ -5,7 +5,7 @@ defmodule Repo.Migrations.AddVersions do create table(:versions) do add :event, :string add :item_type, :string - add :item_id, :integer + add :item_id, :uuid add :item_changes, :map add :origin, :string add :originator_id, references(:people)