# `MishkaDocument.Resources.Changes.DetachVersion`
[🔗](https://github.com/mishka-group/mishka_document/blob/v0.0.1/lib/mishka_document/resources/__changes/detach_version.ex#L5)

Makes a cloned version independent of the version it was cloned from, in one transaction:

  * the version names no source (`source_version_id` nil);
  * none of its pages names the page it was copied from (`MishkaDocument.Section`'s
    `:detach_source`), archived ones included, so deleting the old source's pages deletes none
    of these;
  * its `MishkaDocument.WorkspaceVersionLineage` rows as the new version are deleted.

Each page keeps its `section_lineage_id`, the id its history across versions is read by, which
no reference ties to a row. Every write is made with the action's actor, under the version's
site. A version with no source is refused.

Once committed, `"document:version:detached"` is fired through
`MishkaInstaller.Event.Hook.call/3` with
`%{version_id: "…", source_version_id: "…", workspace_id: "…", site_id: "…", pages: 172}` and
`meta: %{actor: actor, site_id: site_id}`. What a plugin answers is not used.

    update :detach do
      change MishkaDocument.Resources.Changes.DetachVersion
    end

# `event`

```elixir
@spec event() :: String.t()
```

The event fired after a version is made independent.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
