   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")
-          })
+          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
-          })
+
+          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)
+    |> elem(1)
   end
 
   @doc """

  """
  def insert!(changeset, options \\ [origin: nil, meta: nil, originator: nil, prefix: nil]) do
    repo = RepoClient.repo()
    repo.transaction(fn ->
      case RepoClient.strict_mode() do
        true ->
          version_id = get_sequence_id("versions") + 1
          changeset_data = case Map.get(changeset, :data) do
            nil -> changeset |> Map.merge(%{
              id: get_sequence_from_model(changeset) + 1,
              first_version_id: version_id,
              current_version_id: version_id
            })
            _ -> changeset.data |> Map.merge(%{
              id: get_sequence_from_model(changeset) + 1,
              first_version_id: version_id,
              current_version_id: version_id
            })
          end
          initial_version = make_version_struct(%{event: "insert"}, changeset_data, options)
            |> repo.insert!
          updated_changeset = changeset |> change(%{
            first_version_id: initial_version.id, current_version_id: initial_version.id
          })
          model = repo.insert!(updated_changeset)
          target_version = make_version_struct(%{event: "insert"}, model, options) |> serialize()
          Version.changeset(initial_version, target_version) |> repo.update!
          model
        _ ->
          model = repo.insert!(changeset)
          make_version_struct(%{event: "insert"}, model, options) |> repo.insert!
          model
      end
    end) |> elem(1)
  end

  @doc """

  """
  def insert(changeset, options \\ [origin: nil, meta: nil, originator: nil, prefix: nil]) do
    repo = RepoClient.repo()

    transaction_order =
      case RepoClient.strict_mode() do
        true ->
          Multi.new()
          |> Multi.run(:initial_version, fn %{} ->
            version_id = get_sequence_id("versions") + 1

            changeset_data =
              Map.get(changeset, :data, changeset)
              |> Map.merge(%{
                id: get_sequence_from_model(changeset) + 1,
                first_version_id: version_id,
                current_version_id: version_id
              })

            initial_version = make_version_struct(%{event: "insert"}, changeset_data, options)
            repo.insert(initial_version)
          end)
          |> Multi.run(:model, fn %{initial_version: initial_version} ->
            updated_changeset =
              changeset
              |> change(%{
                first_version_id: initial_version.id,
                current_version_id: initial_version.id
              })

            repo.insert(updated_changeset)
          end)
          |> Multi.run(:version, fn %{initial_version: initial_version, model: model} ->
            target_version =
              make_version_struct(%{event: "insert"}, model, options) |> serialize()

            Version.changeset(initial_version, target_version) |> repo.update
          end)

        _ ->
          Multi.new()
          |> Multi.insert(:model, changeset)
          |> Multi.run(:version, fn %{model: model} ->
            version = make_version_struct(%{event: "insert"}, model, options)
            repo.insert(version)
          end)
      end

    transaction = repo.transaction(transaction_order)

