# `PhoenixMicro.Schema.Registry`
[🔗](https://github.com/iamkanishka/phoenix_micro/blob/v1.0.0/lib/phoenix_micro/schema/registry.ex#L1)

ETS-backed registry mapping topic names to their schema modules.

Schemas self-register via `@after_compile` hooks when you `use PhoenixMicro.Schema`.
You can also register programmatically:

    PhoenixMicro.Schema.Registry.register(MyApp.Events.PaymentCreated)

The registry stores multiple versions per topic so you can query the history:

    PhoenixMicro.Schema.Registry.versions("payments.created")
    # => [{1, MyApp.Events.PaymentCreatedV1}, {2, MyApp.Events.PaymentCreated}]

# `all`

```elixir
@spec all() :: [module()]
```

Returns all registered schema modules (deduplicated).

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `clear`

```elixir
@spec clear() :: :ok
```

Removes all entries (useful in tests).

# `lookup`

```elixir
@spec lookup(String.t()) :: {:ok, module()} | {:error, :not_found}
```

Returns the latest-version schema module for a topic.
Returns `{:error, :not_found}` if no schema is registered.

# `register`

```elixir
@spec register(module()) :: :ok
```

Registers a schema module under its declared topic and version.
Safe to call multiple times (idempotent).

# `start_link`

```elixir
@spec start_link(keyword()) :: GenServer.on_start()
```

# `versions`

```elixir
@spec versions(String.t()) :: [{pos_integer(), module()}]
```

Returns all registered `{version, module}` pairs for a topic, oldest first.

---

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