ch-migrate-cli 0.5.0__tar.gz → 0.5.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/PKG-INFO +4 -4
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/README.md +3 -3
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/__init__.py +1 -1
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/cli.py +5 -2
- ch_migrate_cli-0.5.1/tests/test_status_command.py +36 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/.gitignore +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/LICENSE +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/authoring.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/bootstrap.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/config.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/connection.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/deps.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/diff.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/display.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/downgrade.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/env.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/helpers.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/hooks.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/introspect.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/lint.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/mv_validate.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/py.typed +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/rebase.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/runner.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/scaffold.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/secrets.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/skills/ch-migrate/SKILL.md +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/sql.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/statements.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/templates/bootstrap/init_users.sql +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/templates/project/alembic.ini.template +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/templates/project/config.yaml.template +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/templates/project/env.local.example.template +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/templates/project/script.py.mako.template +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/ui.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/clickhouse_alembic/__init__.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/pyproject.toml +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/integration/conftest.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/integration/test_irreversible.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/integration/test_lint_pending.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/integration/test_readme_quickstart.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/integration/test_run_sql.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/integration/test_smoke.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/integration/test_sql_first.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/test_bootstrap.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/test_compat_import.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/test_config.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/test_deps.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/test_diff.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/test_display.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/test_downgrade.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/test_helpers.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/test_hooks.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/test_introspect.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/test_lint.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/test_mv_validate.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/test_new.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/test_package.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/test_readme.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/test_rebase.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/test_scaffold.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/test_secrets.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/test_snapshot.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/test_sql.py +0 -0
- {ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/tests/test_statements.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: ch-migrate-cli
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.1
|
|
4
4
|
Summary: SQL-first ClickHouse schema migrations across environments: the ch-migrate command
|
|
5
5
|
Project-URL: Homepage, https://github.com/DRYCodeWorks/ch-migrate
|
|
6
6
|
Project-URL: Repository, https://github.com/DRYCodeWorks/ch-migrate
|
|
@@ -58,7 +58,7 @@ pip install ch-migrate-cli
|
|
|
58
58
|
ch-migrate --version
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
The command is `ch-migrate`, the PyPI package is `ch-migrate-cli` (PyPI treats `ch-migrate` as the same name as the existing, unrelated `chmigrate`), and migrations import from `ch_migrate`. Versions up to 0.4.1 were published as `clickhouse-alembic` with the import package `clickhouse_alembic`; that import still works with a deprecation warning until 1.0, so existing migration files keep running. Replace `clickhouse_alembic` with `ch_migrate` in them when convenient
|
|
61
|
+
The command is `ch-migrate`, the PyPI package is `ch-migrate-cli` (PyPI treats `ch-migrate` as the same name as the existing, unrelated `chmigrate`), and migrations import from `ch_migrate`. Versions up to 0.4.1 were published as `clickhouse-alembic` with the import package `clickhouse_alembic`; that import still works with a deprecation warning until 1.0, so existing migration files keep running. Replace `clickhouse_alembic` with `ch_migrate` in them when convenient. For `migrations/env.py`, run `ch-migrate upgrade-env` only if you never edited it; if you did (for example to add connection settings), change its `clickhouse_alembic` imports to `ch_migrate` by hand instead, because `upgrade-env` replaces the whole file.
|
|
62
62
|
|
|
63
63
|
To switch an existing install, remove the old package first, because both install the `ch-migrate` command and the `clickhouse_alembic` folder: `uv tool uninstall clickhouse-alembic && uv tool install ch-migrate-cli`, or `pip uninstall clickhouse-alembic && pip install ch-migrate-cli`. In a project that lists `clickhouse-alembic` as a dependency, replace it with `ch-migrate-cli`.
|
|
64
64
|
|
|
@@ -285,7 +285,7 @@ Example: `ch-migrate down dev --revision base`
|
|
|
285
285
|
|
|
286
286
|
### `status`
|
|
287
287
|
|
|
288
|
-
`ch-migrate status ENV` shows connection information, applied/pending counts, and head status, and names the `up` command when migrations are pending. No command-specific options.
|
|
288
|
+
`ch-migrate status ENV` shows connection information, applied/pending counts, and head status, and names the `up` command when migrations are pending. No command-specific options. Status is a report: it exits 0 when the database is unreachable (with a warning) or migrations are pending, and exits 1 only when the configuration or `migrations/versions/` is missing, so CI can run it as a non-blocking check.
|
|
289
289
|
|
|
290
290
|
Example: `ch-migrate status dev`
|
|
291
291
|
|
|
@@ -335,7 +335,7 @@ Example: `ch-migrate rebase dev --onto abc123 --dry-run`
|
|
|
335
335
|
|
|
336
336
|
### `upgrade-env`
|
|
337
337
|
|
|
338
|
-
`ch-migrate upgrade-env` replaces `migrations/env.py` with the installed version and backs up the old file as `env.py.bak`. No command-specific options.
|
|
338
|
+
`ch-migrate upgrade-env` replaces `migrations/env.py` with the installed version and backs up the old file as `env.py.bak`. No command-specific options. It does not merge: any local customizations (connection settings, session pins, hooks) are dropped from the new file. Reapply them from the backup, or skip `upgrade-env` and edit a customized `env.py` by hand.
|
|
339
339
|
|
|
340
340
|
Example: `ch-migrate upgrade-env`
|
|
341
341
|
|
|
@@ -15,7 +15,7 @@ pip install ch-migrate-cli
|
|
|
15
15
|
ch-migrate --version
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
The command is `ch-migrate`, the PyPI package is `ch-migrate-cli` (PyPI treats `ch-migrate` as the same name as the existing, unrelated `chmigrate`), and migrations import from `ch_migrate`. Versions up to 0.4.1 were published as `clickhouse-alembic` with the import package `clickhouse_alembic`; that import still works with a deprecation warning until 1.0, so existing migration files keep running. Replace `clickhouse_alembic` with `ch_migrate` in them when convenient
|
|
18
|
+
The command is `ch-migrate`, the PyPI package is `ch-migrate-cli` (PyPI treats `ch-migrate` as the same name as the existing, unrelated `chmigrate`), and migrations import from `ch_migrate`. Versions up to 0.4.1 were published as `clickhouse-alembic` with the import package `clickhouse_alembic`; that import still works with a deprecation warning until 1.0, so existing migration files keep running. Replace `clickhouse_alembic` with `ch_migrate` in them when convenient. For `migrations/env.py`, run `ch-migrate upgrade-env` only if you never edited it; if you did (for example to add connection settings), change its `clickhouse_alembic` imports to `ch_migrate` by hand instead, because `upgrade-env` replaces the whole file.
|
|
19
19
|
|
|
20
20
|
To switch an existing install, remove the old package first, because both install the `ch-migrate` command and the `clickhouse_alembic` folder: `uv tool uninstall clickhouse-alembic && uv tool install ch-migrate-cli`, or `pip uninstall clickhouse-alembic && pip install ch-migrate-cli`. In a project that lists `clickhouse-alembic` as a dependency, replace it with `ch-migrate-cli`.
|
|
21
21
|
|
|
@@ -242,7 +242,7 @@ Example: `ch-migrate down dev --revision base`
|
|
|
242
242
|
|
|
243
243
|
### `status`
|
|
244
244
|
|
|
245
|
-
`ch-migrate status ENV` shows connection information, applied/pending counts, and head status, and names the `up` command when migrations are pending. No command-specific options.
|
|
245
|
+
`ch-migrate status ENV` shows connection information, applied/pending counts, and head status, and names the `up` command when migrations are pending. No command-specific options. Status is a report: it exits 0 when the database is unreachable (with a warning) or migrations are pending, and exits 1 only when the configuration or `migrations/versions/` is missing, so CI can run it as a non-blocking check.
|
|
246
246
|
|
|
247
247
|
Example: `ch-migrate status dev`
|
|
248
248
|
|
|
@@ -292,7 +292,7 @@ Example: `ch-migrate rebase dev --onto abc123 --dry-run`
|
|
|
292
292
|
|
|
293
293
|
### `upgrade-env`
|
|
294
294
|
|
|
295
|
-
`ch-migrate upgrade-env` replaces `migrations/env.py` with the installed version and backs up the old file as `env.py.bak`. No command-specific options.
|
|
295
|
+
`ch-migrate upgrade-env` replaces `migrations/env.py` with the installed version and backs up the old file as `env.py.bak`. No command-specific options. It does not merge: any local customizations (connection settings, session pins, hooks) are dropped from the new file. Reapply them from the backup, or skip `upgrade-env` and edit a customized `env.py` by hand.
|
|
296
296
|
|
|
297
297
|
Example: `ch-migrate upgrade-env`
|
|
298
298
|
|
|
@@ -250,14 +250,17 @@ def status(environment: str) -> None:
|
|
|
250
250
|
"""Show migration status.
|
|
251
251
|
|
|
252
252
|
Displays environment info, applied/pending counts, and head status.
|
|
253
|
-
|
|
253
|
+
Status is a report: it exits 0 even when the database cannot be reached or
|
|
254
|
+
migrations are pending, and exits 1 only when the config or migrations/versions/
|
|
255
|
+
is missing. CI jobs use it as a non-blocking reporter.
|
|
254
256
|
"""
|
|
255
257
|
from ch_migrate.display import render_status
|
|
256
258
|
|
|
257
259
|
state = _load_migration_state(environment)
|
|
258
260
|
render_status(environment, state.env_config, state.graph, state.applied, db_error=state.db_error)
|
|
259
261
|
if state.db_error:
|
|
260
|
-
ui.
|
|
262
|
+
ui.warn(f"Could not reach the database: {state.db_error.strip().splitlines()[0]}")
|
|
263
|
+
return
|
|
261
264
|
pending = len(set(state.graph.migrations) - (state.applied or set()))
|
|
262
265
|
if pending:
|
|
263
266
|
noun = "migration" if pending == 1 else "migrations"
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""`ch-migrate status` is a report: CI runs it as a non-blocking check.
|
|
2
|
+
|
|
3
|
+
Sazabi's required "ClickHouse Migration Status" job relies on status exiting 0 when
|
|
4
|
+
the database is unreachable or migrations are pending; only a broken project fails.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import pytest
|
|
8
|
+
from click.testing import CliRunner
|
|
9
|
+
|
|
10
|
+
from ch_migrate import connection
|
|
11
|
+
from ch_migrate.cli import main
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@pytest.fixture
|
|
15
|
+
def project(tmp_path, monkeypatch):
|
|
16
|
+
result = CliRunner().invoke(main, ["init", str(tmp_path), "--name", "demo"])
|
|
17
|
+
assert result.exit_code == 0, result.output
|
|
18
|
+
monkeypatch.chdir(tmp_path)
|
|
19
|
+
monkeypatch.setenv("CH_DEV_MIGRATION_PASSWORD", "test-only")
|
|
20
|
+
return tmp_path
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_unreachable_database_is_reported_and_exits_zero(project, monkeypatch):
|
|
24
|
+
def refuse(env_config):
|
|
25
|
+
raise ConnectionError("Connection refused")
|
|
26
|
+
|
|
27
|
+
monkeypatch.setattr(connection, "get_current_heads", refuse)
|
|
28
|
+
result = CliRunner().invoke(main, ["status", "dev"])
|
|
29
|
+
assert result.exit_code == 0, result.output
|
|
30
|
+
assert "Could not reach the database: Connection refused" in result.output
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def test_unknown_environment_fails(project):
|
|
34
|
+
result = CliRunner().invoke(main, ["status", "nope"])
|
|
35
|
+
assert result.exit_code == 1
|
|
36
|
+
assert "Unknown environment: nope" in result.output
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/templates/project/alembic.ini.template
RENAMED
|
File without changes
|
{ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/templates/project/config.yaml.template
RENAMED
|
File without changes
|
|
File without changes
|
{ch_migrate_cli-0.5.0 → ch_migrate_cli-0.5.1}/ch_migrate/templates/project/script.py.mako.template
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|