Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
replace clickhouse-jdbc-driver from ru.yandex.clickhouse(0.3.1) to com.clickhouse(version 0.3.2)
liquibase version from 4.6.1 to 4.15.0
testcontainer from 1.15.3 to 1.17.3
resolve Transactions are not supported error
Add mutations_sync setting to ALTER statements
  • Loading branch information
杨旭 committed Feb 15, 2023
1 parent 779ebb9 commit 710e49a
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 15 deletions.
11 changes: 6 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -66,10 +67,10 @@
<project.build.sourceEncoding>${encoding}</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<clickhouse-jdbc.version>0.3.1</clickhouse-jdbc.version>
<liquibase.version>4.6.1</liquibase.version>
<clickhouse-jdbc.version>0.3.2</clickhouse-jdbc.version>
<liquibase.version>4.15.0</liquibase.version>
<junit.version>5.4.0</junit.version>
<test-containers.version>1.15.3</test-containers.version>
<test-containers.version>1.17.3</test-containers.version>
<nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
<maven-plugin-plugin.version>3.6.0</maven-plugin-plugin.version>
<maven-surefire-plugin.version>2.22.1</maven-surefire-plugin.version>
Expand All @@ -86,7 +87,7 @@

<dependencies>
<dependency>
<groupId>ru.yandex.clickhouse</groupId>
<groupId>com.clickhouse</groupId>
<artifactId>clickhouse-jdbc</artifactId>
<version>${clickhouse-jdbc.version}</version>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* Liquibase extension for Clickhouse
* %%
* Copyright (C) 2020 - 2022 Mediarithmics
* Copyright (C) 2020 - 2023 Mediarithmics
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,10 +22,10 @@
import java.text.SimpleDateFormat;
import java.util.Date;

import com.clickhouse.jdbc.ClickHouseDriver;
import liquibase.database.AbstractJdbcDatabase;
import liquibase.database.DatabaseConnection;
import liquibase.exception.DatabaseException;
import ru.yandex.clickhouse.ClickHouseDriver;

public class ClickHouseDatabase extends AbstractJdbcDatabase {

Expand Down Expand Up @@ -91,4 +91,9 @@ public boolean supportsSequences() {
public boolean supportsSchemas() {
return false;
}

@Override
public boolean supportsDDLInTransaction() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public Sql[] generateSql(
String.format(
"ALTER TABLE %s.%s "
+ SqlGeneratorUtil.generateSqlOnClusterClause(properties)
+ "DELETE WHERE 1",
+ "DELETE WHERE 1 SETTINGS mutations_sync = 1",
database.getDefaultSchemaName(),
database.getDatabaseChangeLogLockTableName());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public Sql[] generateSql(
String.format(
"ALTER TABLE %s.%s "
+ SqlGeneratorUtil.generateSqlOnClusterClause(properties)
+ "UPDATE LOCKED = 1,LOCKEDBY = '%s',LOCKGRANTED = %s WHERE ID = 1 AND LOCKED = 0",
+ "UPDATE LOCKED = 1,LOCKEDBY = '%s',LOCKGRANTED = %s WHERE ID = 1 AND LOCKED = 0 SETTINGS mutations_sync = 1",
database.getDefaultSchemaName(),
database.getDatabaseChangeLogLockTableName(),
host,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public Sql[] generateSql(
String.format(
"ALTER TABLE %s.%s "
+ SqlGeneratorUtil.generateSqlOnClusterClause(properties)
+ "DELETE WHERE ID = '%s' AND AUTHOR = '%s' AND FILENAME = '%s'",
+ "DELETE WHERE ID = '%s' AND AUTHOR = '%s' AND FILENAME = '%s' SETTINGS mutations_sync = 1",
database.getDefaultSchemaName(),
database.getDatabaseChangeLogTableName(),
changeSet.getId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public Sql[] generateSql(
+ dateColumnNameEscaped
+ " DESC, "
+ orderColumnNameEscaped
+ " DESC LIMIT 1)")
+ " DESC LIMIT 1) SETTINGS mutations_sync = 1")
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public Sql[] generateSql(
String.format(
"ALTER TABLE %s.%s "
+ SqlGeneratorUtil.generateSqlOnClusterClause(properties)
+ "UPDATE LOCKED = 0,LOCKEDBY = null, LOCKGRANTED = null WHERE ID = 1 AND LOCKED = 1",
+ "UPDATE LOCKED = 0,LOCKEDBY = null, LOCKGRANTED = null WHERE ID = 1 AND LOCKED = 1 SETTINGS mutations_sync = 1",
database.getDefaultSchemaName(),
database.getDatabaseChangeLogLockTableName());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public Sql[] generateSql(
String.format(
"ALTER TABLE %s.%s "
+ SqlGeneratorUtil.generateSqlOnClusterClause(properties)
+ "UPDATE MD5SUM = '%s' WHERE ID = '%s' AND AUTHOR = '%s' AND FILENAME = '%s'",
+ "UPDATE MD5SUM = '%s' WHERE ID = '%s' AND AUTHOR = '%s' AND FILENAME = '%s' SETTINGS mutations_sync = 1",
database.getDefaultSchemaName(),
database.getDatabaseChangeLogTableName(),
changeSet.generateCheckSum().toString(),
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/liquibase/ClickHouseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* Liquibase extension for Clickhouse
* %%
* Copyright (C) 2020 - 2022 Mediarithmics
* Copyright (C) 2020 - 2023 Mediarithmics
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -37,7 +37,7 @@ public class ClickHouseTest {

@Container
private static ClickHouseContainer clickHouseContainer =
new ClickHouseContainer("yandex/clickhouse-server:20.3");
new ClickHouseContainer("clickhouse/clickhouse-server:22.3.8.39");

@Test
void canInitializeLiquibaseSchema() {
Expand Down

0 comments on commit 710e49a

Please sign in to comment.