Repository navigation
ch-migrate 0.9.0: declarative users, roles and grants - #18
Merged
Merged
Conversation
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 -Ureaches 0.9, so the CHANGELOG opens with upgrade notes. In short:access.yamlkeeps 0.8's grants.bootstrapnow attempts every grant, names each one that fails, and checks the result logged in as the migration user.bootstrapand the access commands need ClickHouse 25.8 or later.initwritesaccess.yaml. Delete it to keep 0.8's behavior.upgrade-envis needed.What's new
access.yamldeclares users, roles, role membership and grants, per environment, with passwords read from secrets.ch-migrate access validate | show | plan | apply | check.planlists the changes, andapplymakes them as the admin: grants before revokes, and revokes only if every earlier change succeeded.core(what migrations need) andlegacy(0.8's grants exactly).Fixes
create_dictionaryworks 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.0is tagged onmainand the release workflow publishes to PyPI.Solves: DRY-1620
🤖 Generated with Claude Code