Identifiers are ULIDs generated Generate ULID identifiers in PHP
- Comparing
- v1 to v2
- Current
- Read the document
Context
Entities need an identity model, and every entity type needs an identifier of its own.
Some rows need their identifier to exist before they are inserted, as outbox rows and queued jobs do.
The panel already depends on symfony/uid, which was added for generating identifiers.
Decision
Entity identifiers are I will identify entities by ULIDs, generated in PHP through symfony/uid before the row is inserted. Each entity , with each entity
type has
given its own entity identifier class, class extending an abstract readonly readonly
EntityId. A , which validates the ULID is validated when an identifier is
constructed, it is constructed and generates a new one through EntityId::make() generates a new identifier.
Alternatives
No alternatives were weighed.
Consequences
Easier:
- An identifier will exist before its row is inserted, as outbox rows and queued jobs need.
- Generating identifiers will not depend on the database, or on the features of any version of it.
Harder:
- A ULID will not be usable as a secret. It embeds a timestamp and a monotonic counter, so one
is guessablecan be guessed from a known one, and identifiers that act as bearer credentials, such as session identifiers, will need a different generator.
Constrained:
- Every entity will be identified by a ULID generated in PHP, never by a value the database generates.
Sources
- Issue #32, Engine - Entities, revision of in its edit history: the
EntityIddesign and the decision, which is bothcreatedanddecided. Its original text of asks only for a simple ORM, with no identity model. composer.jsonat 7fad8cd, the initial commit:symfony/uid, added for generating identifiers before the design was written.- Issue #51, Engine - Database - PostgreSQL, : the reason, that an identifier must exist before the insert for outbox rows and queued jobs, and generation in PHP not needing any database feature. It was first written down here, three months after the decision.
- Issue #67, Engine - Sessions, : why a ULID is not usable as a session identifier, taken from what followed rather than anticipated.
Source adr/0011-ulid-identifiers.md · commit 9444a99 · published