MEDIARITHMICS / liquibase-clickhouse

Apache License 2.0
43 stars 39 forks source link

All queries executes to 'default' database #10

Closed codemistake closed 2 years ago

codemistake commented 3 years ago

I ran into a problem, there is a database called "dbname" and there is a sql changelog

CREATE TABLE ping (
    ID UInt8,
    `data.message` String,
    created_at DateTime('Europe/Moscow')
) ENGINE MergeTree() ORDER BY ID

properties.file

changeLogFile=changelog.xml
classpath=changelog/clickhouse
url=jdbc:clickhouse://clickhouse:8123/dbname
username=default
password=1212
driver=shaded.liquibase.ru.yandex.clickhouse.ClickHouseDriver
databaseClass=liquibase.ext.clickhouse.database.ClickHouseDatabase
strict=false

Migration result:

dbname table list: DATABASECHANGELOG, DATABASECHANGELOGLOCK
default db table list: ping

Whatever I write the name of the database, requests still go to "default". I tried to make another user, with 1 of my database, who does not know about the existence of the "default" database, I still get the system tables in its database, and an error when creating a query to a non-existent database

profixy commented 3 years ago

try add to properties, will it work? database=dbname

codemistake commented 3 years ago

@profixy I tried to do it, but this has no effect

igorepim commented 3 years ago

@profixy You can prefix the name of the table by the name of the database. Like CREATE TABLE dbname.ping (...

profixy commented 3 years ago

No I cant. Imagine pipeline contains dev, qa, beta, prod databases with same tables. Do we need to edit sql changesets (change prefixes) every time before execute it with liquibase?

igorepim commented 2 years ago

Apparently, this problem is caused by clickhouse-jdbc driver v0.3.1: https://github.com/ClickHouse/clickhouse-jdbc/issues/648 But the fixed version 0.3.1-patch introduces another problem with transactions. May be, you can try v0.3.0 as a workaround.

igorepim commented 2 years ago

Update: normally, the new 0.3.2 fixes all problems. To be checked.