Skip to content

Clickhouse schema_migrations table creation fails when ReplicatedMergeTree parameters are given #1097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
davidgcameron opened this issue May 30, 2024 · 0 comments

Comments

@davidgcameron
Copy link

Describe the Bug

If parameters are given to ReplicatedMergeTree, the CREATE TABLE query fails because it is missing the ORDER BY statement. This is because the code simply checks for table ending in "Tree" before adding this statement. (https://github.com/golang-migrate/migrate/blob/master/database/clickhouse/clickhouse.go#L251).

Steps to Reproduce
Steps to reproduce the behavior:

  1. Use a Clickhouse URL with x-migrations-table-engine=ReplicatedMergeTree(%27/clickhouse/tables/all/{database}/{uuid}%27,%27{replica}%27)
  2. Run migrations
  3. Get an error error: code: 42, message: There was an error on [localhost:9000]: Code: 42. DB::Exception: ORDER BY or PRIMARY KEY clause is missing.

There is a workaround: add the ORDER BY to the URL option like this

x-migrations-table-engine=ReplicatedMergeTree(%27/clickhouse/tables/all/{database}/{uuid}%27,%27{replica}%27)%20ORDER%20BY%20sequence

Expected Behavior
Migration succeeds in creating the table with the desired parameters

Migrate Version
4.17.0

Loaded Source Drivers

Source drivers: github, bitbucket, godoc-vfs, s3, go-bindata, file, github-ee, gitlab, gcs

Loaded Database Drivers

Database drivers: mongodb+srv, cockroachdb, postgres, redshift, yugabyte, ysql, stub, clickhouse, cassandra, neo4j, spanner, postgresql, rqlite, mongodb, firebird, pgx, pgx5, cockroach, crdb-postgres, sqlserver, firebirdsql, mysql, pgx4, yugabytedb

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

No branches or pull requests

1 participant