Skip to content

Conversation

@FatherCandle
Copy link
Contributor

@FatherCandle FatherCandle commented Dec 26, 2025

This PR addresses issue #489 by adding comprehensive support for ClickHouse HTTP/S protocols and allowing users to explicitly specify the driver via a CLI flag.

Key Changes:

  1. New Driver Schemes:
  • Added support for clickhouse+http:// and clickhouse+https:// schemes.
  • Added support for clickhouse+tcp:// alias.
  • When these schemes are detected, the driver automatically normalizes the URL for the underlying clickhouse-go driver and sets the appropriate default ports (8123 for HTTP, 8443 for HTTPS) if not specified.
  1. Explicit Driver Selection (--driver flag):
  • Introduced a new global flag: --driver (env: DBMATE_DRIVER).
  • This allows users to force a specific driver, overriding the default behavior of inferring the driver from the database URL scheme.
  • Use Case: Enabling ClickHouse users to provide a standard http:// URL while explicitly telling dbmate to use the ClickHouse driver.
# Using new schemes (auto-detection)
dbmate -u "clickhouse+http://localhost:8123/default" status

# Using standard HTTP scheme with explicit driver flag
dbmate --driver clickhouse -u "http://localhost:8123/default" status

Related Issue
Fixes #489

Type of change
[x] New feature (non-breaking change which adds functionality)
[ ] Bug fix (non-breaking change which fixes an issue)

Checklist
[x] I have added tests to cover the new schemes, port defaults, and flag logic.
[x] I have updated the README.md with documentation for the new feature.
[x] Existing tests passed locally.
[x] Refactored main.go logic into configureDB for better testability.


Note

  • ClickHouse connectivity: clickhouse driver now accepts clickhouse+http:// and clickhouse+https:// schemes (normalized to http/https with default ports 8123/8443) and retains native TCP defaults; connection string handling updated accordingly.
  • Explicit driver selection: New global --driver flag (env: DBMATE_DRIVER) to override driver inference; DB.DriverName added and respected in DB.Driver().
  • CLI refactor for testability: Extracted configureDB from action in main.go to centralize DB initialization.
  • Docs & tests: README updated with new flag and ClickHouse URL examples; comprehensive unit tests added for driver override, ClickHouse schemes/ports, and CLI flag/env precedence.

Written by Cursor Bugbot for commit 3a1f6d1. This will update automatically on new commits. Configure here.

@FatherCandle
Copy link
Contributor Author

@amacneil @dossy
FYI

Failing tests are not related to this PR and change, seems to be issues existing in main branch :(

@dossy
Copy link
Collaborator

dossy commented Dec 27, 2025

Failing tests are not related to this PR and change, seems to be issues existing in main branch :(

Yes, I have a PR that's been needing a review to address the MySQL test failure: #679. This has been blocked for a while, waiting for a review. I know @amacneil has been busy, so I haven't been harassing him, but we do need to get things unblocked at some point so we can move forward.

There's also the issue of PostgreSQL 17.6 introducing the \restrict and \unrestrict meta-command in pgdump output, which also breaks our tests. There's two PRs (#677, #704) that attempt to address this in different ways: #677 is a bit more invasive of a change than #704, so I'm more inclined to approve #704 in the short term to get CI passing, and then debate whether the change in #677 is the correct way to handle things or not.

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.

Support all DSN variants for clickhouse DATABASE_URL

2 participants