# `StatifierPersistence.Ecto.KeyGenerator.UUIDv7`
[🔗](https://github.com/riddler/statifier_persistence/blob/v0.18.0/lib/statifier_persistence/ecto/key_generator/uuid_v7.ex#L2)

RFC 9562 UUIDv7 keys (ADR-0002 decision 2).

`:uuid` keys are generated as UUIDv7, not v4: random keys fragment
b-tree indexes, and v7's 48-bit millisecond timestamp keeps insertion
locality. Generation is implemented here - `Ecto.UUID` generates v4,
and a dependency for one function is not worth taking. Schema fields
are `Ecto.UUID` over `:uuid` columns.

# `generate`

```elixir
@spec generate() :: Ecto.UUID.t()
```

Generates an RFC 9562 UUIDv7 as a canonical hyphenated string.

Layout: 48-bit Unix millisecond timestamp, 4-bit version (7), 12
random bits, 2-bit variant (`10`), 62 random bits.

---

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