StatifierPersistence.Ecto.KeyGenerator.UUIDv7 (StatifierPersistence v0.1.0)

Copy Markdown View Source

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.

Summary

Functions

Generates an RFC 9562 UUIDv7 as a canonical hyphenated string.

Functions

generate()

@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.