# `BaileysEx.Auth.PersistenceMigration`
[🔗](https://github.com/jeffhuen/baileys_ex/blob/main/lib/baileys_ex/auth/persistence_migration.ex#L1)

Explicit migration helpers between built-in auth persistence backends.

Phase 15 keeps `BaileysEx.Auth.FilePersistence` as the Baileys-compatible
JSON helper and introduces `BaileysEx.Auth.NativeFilePersistence` as the
recommended durable backend. This module provides the one-step migration path
between those built-in backends without forcing users to re-pair.

The JSON helper exists as a compatibility bridge for users migrating away
from Baileys JS sidecars. This module is the explicit off-ramp from that
bridge to the Elixir-first native backend.

Migration is explicit. The built-in auth helpers do not convert existing auth
directories automatically during `connect/2`.

# `migration_summary`

```elixir
@type migration_summary() :: %{
  source_backend: module(),
  target_backend: module(),
  source_path: Path.t(),
  target_path: Path.t(),
  migrated_keys: non_neg_integer()
}
```

Summary returned after a successful built-in backend migration.

# `migrate_compat_json_to_native`

```elixir
@spec migrate_compat_json_to_native(Path.t(), Path.t(), keyword()) ::
  {:ok, migration_summary()} | {:error, term()}
```

Migrates a compatibility JSON auth directory into the native durable backend.

The source directory is left untouched. By default the target path must be
missing or empty and must not already contain native backend artifacts unless
`overwrite?: true` is given.

---

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