# `AshClickhouse.DataLayer.Extension`
[🔗](https://github.com/ohhi-vn/ash_clickhouse/blob/main/lib/ash_clickhouse/data_layer/extension.ex#L1)

Integration point that exposes `ash_clickhouse` to the standard Ash mix tasks.

`mix ash.codegen` and `mix ash.migrate` scan the application for modules that
implement `Spark.Dsl.Extension` and invoke `codegen/1` and `migrate/1` on each
of them. This module fills that role for ClickHouse:

* `codegen/1` prints the `CREATE TABLE` / `ALTER TABLE` statements that Ash
  would run for every resource with a working `migrate?` flag, without
  touching the database.
* `migrate/1` runs those statements against every configured repo, matching
  the behaviour of `mix ash_clickhouse.migrate`.

The ClickHouse DSL is a lightweight macro layer (see
`AshClickhouse.DataLayer.Dsl.Macros`) rather than a full Spark DSL section, so
this extension declares no sections of its own — it exists purely so that the
Ash tasks discover and orchestrate the ClickHouse codegen/migrate pipeline.

# `codegen`

```elixir
@spec codegen([String.t()]) :: :ok | no_return()
```

Prints the DDL that `mix ash.migrate` would apply, without applying it.

Accepts the `--dry-run` / `--check` flags forwarded by `mix ash.codegen`.
Passing `--check` exits with a non-zero status when there is pending DDL, so
it can be used in CI.

# `migrate`

```elixir
@spec migrate([String.t()]) :: :ok
```

Applies the pending ClickHouse changes for all configured resources.

# `name`

The name shown by `mix ash.codegen` / `mix ash.migrate` for this extension.

---

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