Skip to content

ch-migrate 0.9.0: declarative users, roles and grants - #18

Merged
drycode merged 1 commit into
mainfrom
dy/ch-migrate-0.9.0
Nov 17, 2026
Merged

drycode merged 1 commit into
mainfrom
dy/ch-migrate-0.9.0

Conversation

@drycode

@drycode drycode commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

ch-migrate 0.9.0 lets a project say, in one file, which users and roles exist and what each may do, and makes a ClickHouse server match it. Until now the migration role got a fixed set of grants, including the right to manage users and roles, and there was no way to declare what any other user should hold. With 0.9, a new project's migration role holds only what migrations need.

What changes for 0.8 projects

A normal pip install -U reaches 0.9, so the CHANGELOG opens with upgrade notes. In short:

  • A project without access.yaml keeps 0.8's grants. bootstrap now attempts every grant, names each one that fails, and checks the result logged in as the migration user.
  • Errors before any change exit 2 instead of 1.
  • bootstrap and the access commands need ClickHouse 25.8 or later.
  • init writes access.yaml. Delete it to keep 0.8's behavior.
  • No upgrade-env is needed.

What's new

  • access.yaml declares users, roles, role membership and grants, per environment, with passwords read from secrets.
  • ch-migrate access validate | show | plan | apply | check. plan lists the changes, and apply makes them as the admin: grants before revokes, and revokes only if every earlier change succeeded.
  • Two built-in migration-role profiles: core (what migrations need) and legacy (0.8's grants exactly).
  • Where users and roles are replicated, as on ClickHouse Cloud, the access commands read every replica and wait for them to agree.

Fixes

  • create_dictionary works with a reader password that starts with :.
  • up's failure report hides every secret ch-migrate has read, including as SQLAlchemy escapes it.

Tests

Unit tests on Python 3.10 to 3.14, plus Docker integration on a single node and a cluster and on ClickHouse 25.8, ran locally. This PR's CI runs the unit and integration matrix again on this tree.

This is one squashed commit: [access] Declare users, roles and grants (0.9.0). After it merges, v0.9.0 is tagged on main and the release workflow publishes to PyPI.

Solves: DRY-1620

🤖 Generated with Claude Code

0.8 gave the migration role a fixed set of grants, including the right
to manage users and roles, and had no way to say what any other user
or role should hold. 0.9 declares users, roles and grants in
access.yaml, per environment. access validate, show, plan, apply and
check compare a server with the file and make it match, logged in as
the admin, so a new project's migration role holds only what
migrations need.

bootstrap runs on the same engine. Without an access.yaml it still
gives 0.8's grants, but attempts every grant and names each one that
fails. apply grants before it revokes, and revokes only if every
earlier change succeeded. Where users and roles are replicated, as on
ClickHouse Cloud, the access commands read every replica.

create_dictionary now works with a reader password that starts with
":", and up's failure report hides every secret ch-migrate has read.
The CHANGELOG's upgrade notes cover what changes for 0.8 projects:
exit 2 for errors before any change, ClickHouse 25.8 or later for
bootstrap and the access commands, and init writing access.yaml.

Solves: DRY-1620 declarative access for 0.9.0
Tests: unit 1167 on Python 3.10-3.14; Docker integration 189 passed,
4 skipped; cluster 43; ClickHouse 25.8 and ClickHouse Cloud suites
(the last three before the final comment and docs cleanup)
@drycode
drycode merged commit ce02fde into main Nov 17, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant