   """
   def delete!(struct, options \\ [origin: nil, meta: nil, originator: nil, prefix: nil]) do
     repo = PaperTrail.RepoClient.repo()
+
     repo.transaction(fn ->
       model = repo.delete!(struct, options)
       version_struct = make_version_struct(%{event: "delete"}, struct, options)
       repo.insert!(version_struct, options)
       model
-    end) |> elem(1)
+    end)
+    |> elem(1)
   end
 
   defp make_version_struct(%{event: "insert"}, model, options) do
     originator = PaperTrail.RepoClient.originator()
     originator_ref = options[originator[:name]] || options[:originator]
+
     %Version{
       event: "insert",
-      item_type: model.__struct__ |> Module.split |> List.last,
+      item_type: model.__struct__ |> Module.split() |> List.last(),
       item_id: model.id,
       item_changes: serialize(model),
-      originator_id: case originator_ref do
-        nil -> nil
-        _ -> originator_ref |> Map.get(:id)
-      end,
+      originator_id:
+        case originator_ref do
+          nil -> nil
+          _ -> originator_ref |> Map.get(:id)
+        end,
       origin: options[:origin],
       meta: options[:meta]
-    } |> add_prefix(options[:prefix])
-  end
+    }
+    |> add_prefix(options[:prefix])
+  end
+
   defp make_version_struct(%{event: "update"}, changeset, options) do
     originator = PaperTrail.RepoClient.originator()
     originator_ref = options[originator[:name]] || options[:originator]
+
     %Version{
       event: "update",
-      item_type: changeset.data.__struct__ |> Module.split |> List.last,
+      item_type: changeset.data.__struct__ |> Module.split() |> List.last(),
       item_id: changeset.data.id,
       item_changes: changeset.changes,
-      originator_id: case originator_ref do
-        nil -> nil
-        _ -> originator_ref |> Map.get(:id)
-      end,
+      originator_id:
+        case originator_ref do
+          nil -> nil
+          _ -> originator_ref |> Map.get(:id)
+        end,
       origin: options[:origin],
       meta: options[:meta]
-    } |> add_prefix(options[:prefix])
-  end
+    }
+    |> add_prefix(options[:prefix])
+  end
+
   defp make_version_struct(%{event: "delete"}, model, options) do
     originator = PaperTrail.RepoClient.originator()
     originator_ref = options[originator[:name]] || options[:originator]
+
     %Version{
       event: "delete",
-      item_type: model.__struct__ |> Module.split |> List.last,
+      item_type: model.__struct__ |> Module.split() |> List.last(),
       item_id: model.id,
       item_changes: serialize(model),
-      originator_id: case originator_ref do
-        nil -> nil
-        _ -> originator_ref |> Map.get(:id)
-      end,
+      originator_id:
+        case originator_ref do
+          nil -> nil
+          _ -> originator_ref |> Map.get(:id)
+        end,
       origin: options[:origin],
       meta: options[:meta]
-    } |> add_prefix(options[:prefix])
+    }
+    |> add_prefix(options[:prefix])
   end
 
   defp get_sequence_from_model(changeset) do
-    table_name = case Map.get(changeset, :data) do
-      nil -> changeset.__struct__.__schema__(:source)
-      _ -> changeset.data.__struct__.__schema__(:source)
-    end
+    table_name =
+      case Map.get(changeset, :data) do
+        nil -> changeset.__struct__.__schema__(:source)
+        _ -> changeset.data.__struct__.__schema__(:source)
+      end
+
     get_sequence_id(table_name)
   end
 
   defp get_sequence_id(table_name) do
     Ecto.Adapters.SQL.query!(RepoClient.repo(), "select last_value FROM #{table_name}_id_seq").rows
-    |> List.first
-    |> List.first
+    |> List.first()
+    |> List.first()
   end
 
   defp serialize(model) do

          {:error, :model, changeset, %{}} ->
            filtered_changes = Map.drop(changeset.changes, [:current_version_id])
            {:error, Map.merge(changeset, %{repo: repo, changes: filtered_changes})}
          {:ok, map} -> {:ok, Map.delete(map, :initial_version)}
        end
      _ ->
        case transaction do
          {:error, :model, changeset, %{}} -> {:error, Map.merge(changeset, %{repo: repo})}

  def update!(changeset, options \\ [origin: nil, meta: nil, originator: nil, prefix: nil]) do
    repo = PaperTrail.RepoClient.repo()
    client = PaperTrail.RepoClient

    repo.transaction(fn ->
      case client.strict_mode() do
        true ->
          version_data =
            changeset.data
            |> Map.merge(%{
              current_version_id: get_sequence_id("versions")
            })

          target_changeset = changeset |> Map.merge(%{data: version_data})
          target_version = make_version_struct(%{event: "update"}, target_changeset, options)
          initial_version = repo.insert!(target_version)
          updated_changeset = changeset |> change(%{current_version_id: initial_version.id})
          model = repo.update!(updated_changeset)

          new_item_changes =
            initial_version.item_changes
            |> Map.merge(%{
              current_version_id: initial_version.id
            })

          initial_version |> change(%{item_changes: new_item_changes}) |> repo.update!
          model

        _ ->
          model = repo.update!(changeset)
          version_struct = make_version_struct(%{event: "update"}, changeset, options)
          repo.insert!(version_struct)
          model
      end
    end)
    |> elem(1)
  end

  @doc """
