-
Notifications
You must be signed in to change notification settings - Fork 282
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
Clickhouse - Allow schema management for multiple databases within the same cluster #515
Conversation
Known issues:
|
The feature/issue seems reasonable to solve. I'm not an expert at clickhouse, but if this is a reasonably common setup then we should support it. Ideally try to align the Will let @dossy do a code review. |
@AndresElizondo Thanks for starting the discussion and drafting this PR. It doesn't appear that ClickHouse has the concept of separate schemas within a database, but rather multiple databases, from what I can tell. This is different than other DBMS's that have databases that contain schemas that contain database objects (tables, views, stored procedures, etc.). If you're looking to dump multiple databases, I would recommend something like the following approach: $ for db in bronze silver gold; do
dbmate --url clickhouse://username:password@hostname:port/$db --schema-file db/${db}.sql dump
done I suppose being able to specify a list of database names and having I'd like to understand whether the |
Hey @dossy, thanks for the quick response! In ClickHouse, the terminology changes, I do not understand the reasoning as it's not explained in the docs.
ClickHouse SQL:
The current behavior in dbmate is like having it work on Postgres for a single schema. The main issue with having multiple folders and running An alternative would be to have all the migrations in a single folder and add a bash script as you mentioned exclusively for the dump process, however, when doing Because of this, I'd argue that even though using the bash script would work, it would be less than ideal. I believe other users will see as much value in this as they do for the Do you agree with my reasoning? |
My understanding of your reply is that, while you could accomplish everything you need without a change to At a minimum, if you could contribute an update to the documentation and the tests to cover this new functionality, I'm not opposed to the change. But, if my understanding is correct, that it doesn't implement any functionality that introduces a capability not previously present, I'm not sure how useful this will be to anyone else. As long as it doesn't break backwards-compatibility so anyone who doesn't need this isn't affected, I don't see the harm in implementing it. But, I'd like to see documentation and tests updated to cover the change, at least. |
Hey guys, after further testing we've come across a blocker. We need multi-query support and my understanding is that |
No problem. For the record on multi-query: We're not against adding it, but I don't want to maintain our own SQL lexer/parser, and I'm not aware of any well-maintained go libraries for that (although I have not researched it recently). If there is an existing library which can appropriately handle all the dialects of SQL we use, it would be much easier to implement in dbmate. |
I can't find anyone doing any complex SQL parsing other than Vitess.io for MySQL. But even then it seems they're splitting by They mention:
I believe this behavior is a good balance for both maintainers and users |
Appreciate the research - sounds like golang-migrate is a good option. I would rather not introduce a naive splitting on semicolon (even if optional). I agree that it could be a useful tradeoff in some situations, but I feel like inevitably someone is going to put a semicolon in the middle of a string and it will break, leading to more issues/bugs being filed. We have pretty minimal maintainers available for dbmate so are trying to keep the potential bug surface area low. |
This PR refers to the idea proposed in #514.
This is a quick implementation, testing is missing, implementation can be cleaner.
Looking to get some feedback before investing more time.
Does this feature seem reasonable? How should it be different?
To use this feature:
.env
On the terminal: