Skip to content
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

Migration on Clickhouse fails if the file only contains a comment #437

Closed
sboomsma opened this issue Sep 4, 2020 · 2 comments
Closed

Migration on Clickhouse fails if the file only contains a comment #437

sboomsma opened this issue Sep 4, 2020 · 2 comments

Comments

@sboomsma
Copy link

sboomsma commented Sep 4, 2020

According to the documentation empty migrations is permitted by migrate (see here)

The migration files are permitted to be "empty", in the event that a migration is a no-op or is irreversible. It is recommended to still include both migration files by making the whole migration file consist of a comment. If your database does not support comments, then deleting the migration file will also work. Note, an actual empty file (e.g. a 0 byte file) may cause issues with your database since migrate will attempt to run an empty query. In this case, deleting the migration file will also work. For the rational of this behavior see: #244 (comment)

It seems for clickhouse that having a file with just a comment still causes an empty query error:

error: migration failed in line 0:  (details: code: 62, message: Empty query)

Steps to Reproduce
Steps to reproduce the behavior:

  1. Create a new clickhouse DB migration, leaving the up migration file empty.
$ migrate -ext migrations -dir migrations empty_up_test
$ echo "-- Empty file, because we need multiple down migrations to under the next up migration" > migrations/2020904120200_empty_up_test.migration
  1. Perform the up migration:
$ migrate -path migrations -source "${MIGRATE_DB}" up
  1. See error

Expected Behavior
I would expect that a up migration file with an empty script would simply update the schema_migrations table to the new version

Migrate Version
4.12.2

Loaded Source Drivers
github, github-ee, gitlab, go-bindata, godoc-vfs, gcs, file, s3

Loaded Database Drivers
cockroachdb, firebird, mysql, sqlserver, cassandra, firebirdsql, redshift, spanner, neo4j, postgres, postgresql, clickhouse, cockroach, crdb-postgres, mongodb, mongodb+srv, stub

Go Version
go version go1.14.4 linux/amd64

@dhui
Copy link
Member

dhui commented Sep 4, 2020

It looks like Clickhouse doesn't support empty queries or queries with only comments. There's nothing actionable for migrate since migrate avoids processing or interpreting migration data/content. e.g. migration content/data is treated as opaque binary blobs
See: #244 (comment)

I find it odd that you're getting the same 1065 MySQL/MariaDB error in Clickhouse

@sboomsma
Copy link
Author

sboomsma commented Sep 7, 2020

Ah yes, I've fixed the original report to the correct 62 code.

Ok, I think the phrasing in the documentation could be improved in this regard but happy to close.

@sboomsma sboomsma closed this as completed Sep 7, 2020
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

2 participants