# Changelog

All notable changes to this project are documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

## [0.2.0](https://github.com/halfdan/ecto_cockroach_extras/releases/tag/v0.2.0) - 2026-08-11

### Added

- `table_sizes/2` and `index_sizes/2` now accept a `tables:` argument to scope
  results to specific tables. Defaults to all tables when omitted.

### Fixed

- Format `Decimal` values correctly in the ASCII table output: decimals typed as
  `:bytes` now render as human-readable byte sizes and `:percent` as percentages,
  rather than raw decimal values.

## [0.1.0](https://github.com/halfdan/ecto_cockroach_extras/releases/tag/v0.1.0) - 2026-08-03

Initial release. Exposes CockroachDB cluster and database statistics for use from
IEx, scripts, or `Phoenix.LiveDashboard`, mimicking the API of
[`ecto_psql_extras`](https://github.com/pawurb/ecto_psql_extras) while querying
CockroachDB's own introspection surface (`SHOW JOBS`, `SHOW CHANGEFEED JOBS`,
`SHOW STATISTICS`, `SHOW CLUSTER SETTINGS`, and the `crdb_internal.*` virtual tables).

### Added

- Core `EctoCockroachExtras` API with the following queries:
  - `jobs/2` and `changefeed_jobs/2`
  - `table_statistics/3`
  - `sessions/2`, `running_queries/2`, `top_queries/2`
  - `locks/2` and `contention/2`
  - `cluster_settings/2` (supports `args: [all: true]` for
    `SHOW ALL CLUSTER SETTINGS` and `args: [pattern: "..."]` for `LIKE` filtering)
  - `index_usage/2`, `unused_indexes/2`
  - `table_sizes/2`, `index_sizes/2`
- `diagnose/2` for running diagnostic checks against a repo, with an optional
  `tables:` argument.
- ASCII table output by default, with `format: :raw` to return the underlying
  `%Postgrex.Result{}` instead.
- `query/3` to run any query by name (e.g. `query(:cluster_settings, repo)`).
- `allow_unsafe_internals` support: `locks`, `index_usage`, and `unused_indexes`
  are gated behind CockroachDB's `allow_unsafe_internals` session variable and are
  delegated to a user-defined `unsafe_internals_query!/3` on the repo so the `SET`
  and the query run on the same connection.
- `Phoenix.LiveDashboard` integration through upstream's per-repo
  `{repo, info_module}` override, so a CockroachDB repo is routed to
  `EctoCockroachExtras` instead of the PostgreSQL-only `EctoPSQLExtras`.
- CI workflow and a test suite that runs real queries against a live CockroachDB
  instance (nothing mocked), configurable via `COCKROACH_*` environment variables.
- Nix flake (`flake.nix`) for a reproducible development environment.
