From 506defa0a3f0b89bafbda5c12a1aa4ee68d5e575 Mon Sep 17 00:00:00 2001 From: Sergey Sazonov Date: Thu, 2 Feb 2023 20:06:37 +0300 Subject: [PATCH 01/20] WIP --- .../ClickHouseConfigurationExtension.java | 26 ++++ .../clickhouse/ClickHouseConnection.java | 27 +++++ .../clickhouse/ClickHouseDatabase.java | 111 ++++++++++++++++++ .../clickhouse/ClickHouseDatabaseType.java | 54 +++++++++ .../database/clickhouse/ClickHouseParser.java | 12 ++ .../database/clickhouse/ClickHouseSchema.java | 63 ++++++++++ .../database/clickhouse/ClickHouseTable.java | 36 ++++++ .../org.flywaydb.core.extensibility.Plugin | 2 + 8 files changed, 331 insertions(+) create mode 100644 flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java create mode 100644 flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConnection.java create mode 100644 flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java create mode 100644 flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabaseType.java create mode 100644 flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseParser.java create mode 100644 flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseSchema.java create mode 100644 flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java new file mode 100644 index 0000000000..8e6d00aa40 --- /dev/null +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java @@ -0,0 +1,26 @@ +package org.flywaydb.community.database.clickhouse; + +import org.flywaydb.core.extensibility.ConfigurationExtension; + +import java.util.Map; + +public class ClickHouseConfigurationExtension implements ConfigurationExtension { + private static final String CLUSTER_NAME = "flyway.clickhouse.clusterName"; + + private String clusterName; + + public String getClusterName() { + return clusterName; + } + + @Override + public void extractParametersFromConfiguration(Map configuration) { + clusterName = configuration.get(CLUSTER_NAME); + configuration.remove(CLUSTER_NAME); + } + + @Override + public String getConfigurationParameterFromEnvironmentVariable(String environmentVariable) { + return null; + } +} diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConnection.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConnection.java new file mode 100644 index 0000000000..a15cdab7de --- /dev/null +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConnection.java @@ -0,0 +1,27 @@ +package org.flywaydb.community.database.clickhouse; + +import org.flywaydb.core.internal.database.base.Connection; + +import java.sql.SQLException; + +public class ClickHouseConnection extends Connection +{ + ClickHouseConnection(ClickHouseDatabase database, java.sql.Connection connection) { + super(database, connection); + } + + @Override + protected String getCurrentSchemaNameOrSearchPath() throws SQLException { + return getJdbcTemplate().getConnection().getSchema(); + } + + @Override + public void doChangeCurrentSchemaOrSearchPathTo(String schema) throws SQLException { + getJdbcTemplate().getConnection().setSchema(schema); + } + + @Override + public ClickHouseSchema getSchema(String name) { + return new ClickHouseSchema(jdbcTemplate, database, name); + } +} diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java new file mode 100644 index 0000000000..510dabd702 --- /dev/null +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java @@ -0,0 +1,111 @@ +package org.flywaydb.community.database.clickhouse; + +import org.flywaydb.core.api.configuration.Configuration; +import org.flywaydb.core.internal.database.base.Database; +import org.flywaydb.core.internal.database.base.Table; +import org.flywaydb.core.internal.jdbc.JdbcConnectionFactory; +import org.flywaydb.core.internal.jdbc.StatementInterceptor; +import org.flywaydb.core.internal.util.StringUtils; + +import java.sql.Connection; + +public class ClickHouseDatabase extends Database +{ + @Override + public boolean useSingleConnection() { + return true; + } + + public ClickHouseDatabase(Configuration configuration, JdbcConnectionFactory jdbcConnectionFactory, StatementInterceptor statementInterceptor) { + super(configuration, jdbcConnectionFactory, statementInterceptor); + } + + @Override + protected ClickHouseConnection doGetConnection(Connection connection) { + return new ClickHouseConnection(this, connection); + } + + @Override + public void ensureSupported() { + } + + @Override + public boolean supportsDdlTransactions() { + return false; + } + + @Override + public boolean supportsMultiStatementTransactions() { + return false; + } + + @Override + public String getBooleanTrue() { + return "1"; + } + + @Override + public String getBooleanFalse() { + return "0"; + } + + @Override + public boolean catalogIsSchema() { + return true; + } + + @Override + public String getRawCreateScript(Table table, boolean baseline) { + String clusterName = configuration.getPluginRegister().getPlugin(ClickHouseConfigurationExtension.class).getClusterName(); + + if (StringUtils.hasText(clusterName)) { + return "CREATE TABLE IF NOT EXISTS " + table + "_local ON CLUSTER " + clusterName + "(" + + " installed_rank Int32," + + " version Nullable(String)," + + " description String," + + " type String," + + " script String," + + " checksum Nullable(Int32)," + + " installed_by String," + + " installed_on DateTime DEFAULT now()," + + " execution_time Int32," + + " success Bool" + + ")" + + " ENGINE = ReplicatedMergeTree(" + + " '/clickhouse/tables/{shard}/" + table.getName() + "'," + + " '{replica}'" + + " )" + + " PARTITION BY tuple()" + + " ORDER BY (installed_rank);" + + (baseline ? getBaselineStatement(table) + ";" : "") + + "CREATE TABLE IF NOT EXISTS " + table + " ON CLUSTER " + clusterName + "(" + + " installed_rank Int32," + + " version Nullable(String)," + + " description String," + + " type String," + + " script String," + + " checksum Nullable(Int32)," + + " installed_by String," + + " installed_on DateTime DEFAULT now()," + + " execution_time Int32," + + " success Bool" + + ")" + " ENGINE = Distributed(" + clusterName + ", " + table.getSchema() + + ", " + table.getName() + "_local, 1)"; + } else { + return "CREATE TABLE IF NOT EXISTS " + table + "(" + + " installed_rank Int32," + + " version Nullable(String)," + + " description String," + + " type String," + + " script String," + + " checksum Nullable(Int32)," + + " installed_by String," + + " installed_on DateTime DEFAULT now()," + + " execution_time Int32," + + " success Bool" + + ")" + + " ENGINE = TinyLog;" + + (baseline ? getBaselineStatement(table) + ";" : ""); + } + } +} diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabaseType.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabaseType.java new file mode 100644 index 0000000000..92c5e35b48 --- /dev/null +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabaseType.java @@ -0,0 +1,54 @@ +package org.flywaydb.community.database.clickhouse; + +import org.flywaydb.core.api.ResourceProvider; +import org.flywaydb.core.api.configuration.Configuration; +import org.flywaydb.core.internal.database.base.BaseDatabaseType; +import org.flywaydb.core.internal.jdbc.JdbcConnectionFactory; +import org.flywaydb.core.internal.jdbc.StatementInterceptor; +import org.flywaydb.core.internal.parser.Parser; +import org.flywaydb.core.internal.parser.ParsingContext; + +import java.sql.Connection; + +public class ClickHouseDatabaseType extends BaseDatabaseType +{ + @Override + public String getName() { + return "ClickHouse"; + } + + @Override + public int getNullType() { + return 0; + } + + @Override + public boolean handlesJDBCUrl(String url) { + return url.startsWith("jdbc:clickhouse:"); + } + + @Override + public String getDriverClass(String url, ClassLoader classLoader) { + return "com.clickhouse.jdbc.ClickHouseDriver"; + } + + @Override + public String getBackupDriverClass(String url, ClassLoader classLoader) { + return "ru.yandex.clickhouse.ClickHouseDriver"; + } + + @Override + public boolean handlesDatabaseProductNameAndVersion(String databaseProductName, String databaseProductVersion, Connection connection) { + return true; + } + + @Override + public ClickHouseDatabase createDatabase(Configuration configuration, JdbcConnectionFactory jdbcConnectionFactory, StatementInterceptor statementInterceptor) { + return new ClickHouseDatabase(configuration, jdbcConnectionFactory, statementInterceptor); + } + + @Override + public Parser createParser(Configuration configuration, ResourceProvider resourceProvider, ParsingContext parsingContext) { + return new ClickHouseParser(configuration, parsingContext, 3); + } +} diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseParser.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseParser.java new file mode 100644 index 0000000000..670a4d6355 --- /dev/null +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseParser.java @@ -0,0 +1,12 @@ +package org.flywaydb.community.database.clickhouse; + +import org.flywaydb.core.api.configuration.Configuration; +import org.flywaydb.core.internal.parser.Parser; +import org.flywaydb.core.internal.parser.ParsingContext; + +public class ClickHouseParser extends Parser +{ + protected ClickHouseParser(Configuration configuration, ParsingContext parsingContext, int peekDepth) { + super(configuration, parsingContext, peekDepth); + } +} diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseSchema.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseSchema.java new file mode 100644 index 0000000000..6559e2155e --- /dev/null +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseSchema.java @@ -0,0 +1,63 @@ +package org.flywaydb.community.database.clickhouse; + +import org.flywaydb.core.internal.database.base.Schema; +import org.flywaydb.core.internal.jdbc.JdbcTemplate; + +import java.sql.SQLException; + +public class ClickHouseSchema extends Schema +{ + /** + * @param jdbcTemplate The Jdbc Template for communicating with the DB. + * @param database The database-specific support. + * @param name The name of the schema. + */ + public ClickHouseSchema(JdbcTemplate jdbcTemplate, ClickHouseDatabase database, String name) { + super(jdbcTemplate, database, name); + } + + @Override + protected boolean doExists() throws SQLException { + int i = jdbcTemplate.queryForInt("SELECT COUNT() FROM system.databases WHERE name = ?", name); + return i > 0; + } + + @Override + protected boolean doEmpty() throws SQLException { + int i = jdbcTemplate.queryForInt("SELECT COUNT() FROM system.tables WHERE database = ?", name); + return i == 0; + } + + @Override + protected void doCreate() throws SQLException { + jdbcTemplate.executeStatement("CREATE DATABASE " + database.quote(name)); + } + + @Override + protected void doDrop() throws SQLException { + if (jdbcTemplate.getConnection().getCatalog().equals(name)) { + jdbcTemplate.getConnection().setCatalog("default"); + } + jdbcTemplate.executeStatement("DROP DATABASE " + database.quote(name)); + } + + @Override + protected void doClean() throws SQLException { + for (ClickHouseTable table : allTables()) { + table.drop(); + } + } + + @Override + protected ClickHouseTable[] doAllTables() throws SQLException { + return jdbcTemplate.queryForStringList("SELECT name FROM system.tables WHERE database = ?", name) + .stream() + .map(this::getTable) + .toArray(ClickHouseTable[]::new); + } + + @Override + public ClickHouseTable getTable(String tableName) { + return new ClickHouseTable(jdbcTemplate, database, this, tableName); + } +} diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java new file mode 100644 index 0000000000..cf25accfe3 --- /dev/null +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java @@ -0,0 +1,36 @@ +package org.flywaydb.community.database.clickhouse; + +import org.flywaydb.core.internal.database.base.Table; +import org.flywaydb.core.internal.jdbc.JdbcTemplate; + +import java.sql.SQLException; + +public class ClickHouseTable extends Table +{ + /** + * @param jdbcTemplate The JDBC template for communicating with the DB. + * @param database The database-specific support. + * @param schema The schema this table lives in. + * @param name The name of the table. + */ + public ClickHouseTable(JdbcTemplate jdbcTemplate, ClickHouseDatabase database, ClickHouseSchema schema, String name) { + super(jdbcTemplate, database, schema, name); + } + + @Override + protected void doDrop() throws SQLException { + jdbcTemplate.executeStatement("DROP TABLE " + database.quote(schema.getName(), name)); + } + + @Override + protected boolean doExists() throws SQLException { + int count = jdbcTemplate.queryForInt( + "SELECT COUNT() FROM system.tables WHERE database = ? AND name = ?", + schema.getName(), name); + return count > 0; + } + + @Override + protected void doLock() throws SQLException { + } +} diff --git a/flyway-community-db-support/src/main/resources/META-INF/services/org.flywaydb.core.extensibility.Plugin b/flyway-community-db-support/src/main/resources/META-INF/services/org.flywaydb.core.extensibility.Plugin index 53193f5374..3a6a2dbdd2 100644 --- a/flyway-community-db-support/src/main/resources/META-INF/services/org.flywaydb.core.extensibility.Plugin +++ b/flyway-community-db-support/src/main/resources/META-INF/services/org.flywaydb.core.extensibility.Plugin @@ -1,3 +1,5 @@ +org.flywaydb.community.database.clickhouse.ClickHouseConfigurationExtension +org.flywaydb.community.database.clickhouse.ClickHouseDatabaseType org.flywaydb.community.database.ignite.thin.IgniteThinDatabaseType org.flywaydb.community.database.mysql.tidb.TiDBDatabaseType org.flywaydb.community.database.yugabytedb.YugabyteDBDatabaseType From 0759babe6870bc876e35d1f0ce15640b29428903 Mon Sep 17 00:00:00 2001 From: Sergey Sazonov Date: Thu, 2 Feb 2023 20:08:41 +0300 Subject: [PATCH 02/20] WIP --- .../database/clickhouse/ClickHouseConfigurationExtension.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java index 8e6d00aa40..a6f93409a6 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java @@ -21,6 +21,9 @@ public void extractParametersFromConfiguration(Map configuration @Override public String getConfigurationParameterFromEnvironmentVariable(String environmentVariable) { + if ("FLYWAY_CLICKHOUSE_CLUSTER_NAME".equals(environmentVariable)) { + return CLUSTER_NAME; + } return null; } } From efd0075632e40302318bff4cfbcc0155795604d6 Mon Sep 17 00:00:00 2001 From: Sergey Sazonov Date: Fri, 3 Feb 2023 10:58:08 +0300 Subject: [PATCH 03/20] WIP --- flyway-community-db-support/pom.xml | 6 +++++- .../clickhouse/ClickHouseConfigurationExtension.java | 6 ++---- .../community/database/clickhouse/ClickHouseDatabase.java | 2 +- .../community/database/clickhouse/ClickHouseTable.java | 3 +++ 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/flyway-community-db-support/pom.xml b/flyway-community-db-support/pom.xml index 91d2994831..1b01f1ac18 100644 --- a/flyway-community-db-support/pom.xml +++ b/flyway-community-db-support/pom.xml @@ -45,6 +45,10 @@ ${version.junit} test + + org.projectlombok + lombok + org.apache.ignite @@ -120,4 +124,4 @@ - \ No newline at end of file + diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java index a6f93409a6..eebdeb513d 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java @@ -1,18 +1,16 @@ package org.flywaydb.community.database.clickhouse; +import lombok.Getter; import org.flywaydb.core.extensibility.ConfigurationExtension; import java.util.Map; +@Getter public class ClickHouseConfigurationExtension implements ConfigurationExtension { private static final String CLUSTER_NAME = "flyway.clickhouse.clusterName"; private String clusterName; - public String getClusterName() { - return clusterName; - } - @Override public void extractParametersFromConfiguration(Map configuration) { clusterName = configuration.get(CLUSTER_NAME); diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java index 510dabd702..28a574480f 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java @@ -104,7 +104,7 @@ public String getRawCreateScript(Table table, boolean baseline) { " execution_time Int32," + " success Bool" + ")" + - " ENGINE = TinyLog;" + + " ENGINE = StripeLog;" + (baseline ? getBaselineStatement(table) + ";" : ""); } } diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java index cf25accfe3..d044d829ea 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java @@ -1,10 +1,12 @@ package org.flywaydb.community.database.clickhouse; +import lombok.CustomLog; import org.flywaydb.core.internal.database.base.Table; import org.flywaydb.core.internal.jdbc.JdbcTemplate; import java.sql.SQLException; +@CustomLog public class ClickHouseTable extends Table { /** @@ -32,5 +34,6 @@ protected boolean doExists() throws SQLException { @Override protected void doLock() throws SQLException { + LOG.debug("Unable to lock " + this + " as ClickHouse does not support locking. No concurrent migration supported."); } } From 86825469fbb5e07fd9e1775fbe83cbb7cad7da5d Mon Sep 17 00:00:00 2001 From: Sergey Sazonov Date: Fri, 3 Feb 2023 11:05:43 +0300 Subject: [PATCH 04/20] WIP --- .../community/database/clickhouse/ClickHouseSchema.java | 4 ++-- .../community/database/clickhouse/ClickHouseTable.java | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseSchema.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseSchema.java index 6559e2155e..fdbf27a9af 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseSchema.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseSchema.java @@ -35,8 +35,8 @@ protected void doCreate() throws SQLException { @Override protected void doDrop() throws SQLException { - if (jdbcTemplate.getConnection().getCatalog().equals(name)) { - jdbcTemplate.getConnection().setCatalog("default"); + if (jdbcTemplate.getConnection().getSchema().equals(name)) { + jdbcTemplate.getConnection().setSchema("default"); } jdbcTemplate.executeStatement("DROP DATABASE " + database.quote(name)); } diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java index d044d829ea..af69e07784 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java @@ -26,9 +26,7 @@ protected void doDrop() throws SQLException { @Override protected boolean doExists() throws SQLException { - int count = jdbcTemplate.queryForInt( - "SELECT COUNT() FROM system.tables WHERE database = ? AND name = ?", - schema.getName(), name); + int count = jdbcTemplate.queryForInt("SELECT COUNT() FROM system.tables WHERE database = ? AND name = ?", schema.getName(), name); return count > 0; } From 10dcb9251b67a1c01275703fc86c18cf2b9672ab Mon Sep 17 00:00:00 2001 From: Sergey Sazonov Date: Fri, 3 Feb 2023 11:11:29 +0300 Subject: [PATCH 05/20] WIP --- flyway-community-db-support/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/flyway-community-db-support/pom.xml b/flyway-community-db-support/pom.xml index 1b01f1ac18..3637e7210c 100644 --- a/flyway-community-db-support/pom.xml +++ b/flyway-community-db-support/pom.xml @@ -55,6 +55,12 @@ ignite-core true + + com.clickhouse + clickhouse-jdbc + 0.4.0 + true + From 4d084e4b0c6ca8dff1ca73ed803c3a20b7f70e1a Mon Sep 17 00:00:00 2001 From: Sergey Sazonov Date: Sun, 26 Feb 2023 21:08:00 +0300 Subject: [PATCH 06/20] Fixed flyway "repair" command by switching to MergeTree engine for history table --- .../database/clickhouse/ClickHouseDatabase.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java index 28a574480f..7f532c66f8 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java @@ -61,7 +61,7 @@ public String getRawCreateScript(Table table, boolean baseline) { if (StringUtils.hasText(clusterName)) { return "CREATE TABLE IF NOT EXISTS " + table + "_local ON CLUSTER " + clusterName + "(" + " installed_rank Int32," + - " version Nullable(String)," + + " version String," + " description String," + " type String," + " script String," + @@ -80,7 +80,7 @@ public String getRawCreateScript(Table table, boolean baseline) { (baseline ? getBaselineStatement(table) + ";" : "") + "CREATE TABLE IF NOT EXISTS " + table + " ON CLUSTER " + clusterName + "(" + " installed_rank Int32," + - " version Nullable(String)," + + " version String," + " description String," + " type String," + " script String," + @@ -90,11 +90,11 @@ public String getRawCreateScript(Table table, boolean baseline) { " execution_time Int32," + " success Bool" + ")" + " ENGINE = Distributed(" + clusterName + ", " + table.getSchema() + - ", " + table.getName() + "_local, 1)"; + ", " + table.getName() + "_local, 1);"; } else { return "CREATE TABLE IF NOT EXISTS " + table + "(" + " installed_rank Int32," + - " version Nullable(String)," + + " version String," + " description String," + " type String," + " script String," + @@ -104,7 +104,8 @@ public String getRawCreateScript(Table table, boolean baseline) { " execution_time Int32," + " success Bool" + ")" + - " ENGINE = StripeLog;" + + " ENGINE = MergeTree" + + " primary key (version);" + (baseline ? getBaselineStatement(table) + ";" : ""); } } From c679432c53a46d668d75c30fe19af3b009d56321 Mon Sep 17 00:00:00 2001 From: Sergey Sazonov Date: Wed, 1 Mar 2023 09:31:19 +0300 Subject: [PATCH 07/20] Reinitializtion support for ClickHouseConfigurationExtension --- .../clickhouse/ClickHouseConfigurationExtension.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java index eebdeb513d..7b523ea587 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java @@ -13,8 +13,10 @@ public class ClickHouseConfigurationExtension implements ConfigurationExtension @Override public void extractParametersFromConfiguration(Map configuration) { - clusterName = configuration.get(CLUSTER_NAME); - configuration.remove(CLUSTER_NAME); + String clusterName = configuration.remove(CLUSTER_NAME); + if (clusterName != null) { + this.clusterName = clusterName; + } } @Override From c9848fc596f129ef00ef6332a18127c9d06a728d Mon Sep 17 00:00:00 2001 From: Sergey Sazonov Date: Wed, 1 Mar 2023 15:21:56 +0300 Subject: [PATCH 08/20] Fix for creating schema tables in clustered configuration --- .../clickhouse/ClickHouseConnection.java | 2 +- .../clickhouse/ClickHouseDatabase.java | 75 +++++++------------ .../database/clickhouse/ClickHouseTable.java | 5 +- 3 files changed, 31 insertions(+), 51 deletions(-) diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConnection.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConnection.java index a15cdab7de..4919312e8a 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConnection.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConnection.java @@ -12,7 +12,7 @@ public class ClickHouseConnection extends Connection @Override protected String getCurrentSchemaNameOrSearchPath() throws SQLException { - return getJdbcTemplate().getConnection().getSchema(); + return database.unQuote(getJdbcTemplate().getConnection().getSchema()); } @Override diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java index 7f532c66f8..b92a21ddd3 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java @@ -20,6 +20,10 @@ public ClickHouseDatabase(Configuration configuration, JdbcConnectionFactory jdb super(configuration, jdbcConnectionFactory, statementInterceptor); } + public String getClusterName() { + return configuration.getPluginRegister().getPlugin(ClickHouseConfigurationExtension.class).getClusterName(); + } + @Override protected ClickHouseConnection doGetConnection(Connection connection) { return new ClickHouseConnection(this, connection); @@ -56,57 +60,30 @@ public boolean catalogIsSchema() { @Override public String getRawCreateScript(Table table, boolean baseline) { - String clusterName = configuration.getPluginRegister().getPlugin(ClickHouseConfigurationExtension.class).getClusterName(); - - if (StringUtils.hasText(clusterName)) { - return "CREATE TABLE IF NOT EXISTS " + table + "_local ON CLUSTER " + clusterName + "(" + - " installed_rank Int32," + - " version String," + - " description String," + - " type String," + - " script String," + - " checksum Nullable(Int32)," + - " installed_by String," + - " installed_on DateTime DEFAULT now()," + - " execution_time Int32," + - " success Bool" + - ")" + - " ENGINE = ReplicatedMergeTree(" + - " '/clickhouse/tables/{shard}/" + table.getName() + "'," + - " '{replica}'" + - " )" + + String clusterName = getClusterName(); + boolean isClustered = StringUtils.hasText(clusterName); + + String script = "CREATE TABLE IF NOT EXISTS " + table + (isClustered ? (" ON CLUSTER " + clusterName) : "") + "(" + + " installed_rank Int32," + + " version String," + + " description String," + + " type String," + + " script String," + + " checksum Nullable(Int32)," + + " installed_by String," + + " installed_on DateTime DEFAULT now()," + + " execution_time Int32," + + " success Bool" + + ")"; + + if (isClustered) { + script += " ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/{database}/{table}', '{replica}')" + " PARTITION BY tuple()" + - " ORDER BY (installed_rank);" + - (baseline ? getBaselineStatement(table) + ";" : "") + - "CREATE TABLE IF NOT EXISTS " + table + " ON CLUSTER " + clusterName + "(" + - " installed_rank Int32," + - " version String," + - " description String," + - " type String," + - " script String," + - " checksum Nullable(Int32)," + - " installed_by String," + - " installed_on DateTime DEFAULT now()," + - " execution_time Int32," + - " success Bool" + - ")" + " ENGINE = Distributed(" + clusterName + ", " + table.getSchema() + - ", " + table.getName() + "_local, 1);"; + " ORDER BY (installed_rank);"; } else { - return "CREATE TABLE IF NOT EXISTS " + table + "(" + - " installed_rank Int32," + - " version String," + - " description String," + - " type String," + - " script String," + - " checksum Nullable(Int32)," + - " installed_by String," + - " installed_on DateTime DEFAULT now()," + - " execution_time Int32," + - " success Bool" + - ")" + - " ENGINE = MergeTree" + - " primary key (version);" + - (baseline ? getBaselineStatement(table) + ";" : ""); + script += " ENGINE = MergeTree PRIMARY KEY (version);"; } + + return script + (baseline ? getBaselineStatement(table) + ";" : ""); } } diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java index af69e07784..c4409131a3 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java @@ -3,6 +3,7 @@ import lombok.CustomLog; import org.flywaydb.core.internal.database.base.Table; import org.flywaydb.core.internal.jdbc.JdbcTemplate; +import org.flywaydb.core.internal.util.StringUtils; import java.sql.SQLException; @@ -21,7 +22,9 @@ public ClickHouseTable(JdbcTemplate jdbcTemplate, ClickHouseDatabase database, C @Override protected void doDrop() throws SQLException { - jdbcTemplate.executeStatement("DROP TABLE " + database.quote(schema.getName(), name)); + String clusterName = database.getClusterName(); + + jdbcTemplate.executeStatement("DROP TABLE " + this + (StringUtils.hasText(clusterName) ? (" ON CLUSTER " + clusterName) : "")); } @Override From 979a65762c2eba4a6341278a65ac09f3df2bb850 Mon Sep 17 00:00:00 2001 From: Sergey Sazonov Date: Wed, 1 Mar 2023 15:46:39 +0300 Subject: [PATCH 09/20] Code-style --- .../community/database/clickhouse/ClickHouseConnection.java | 3 +-- .../community/database/clickhouse/ClickHouseDatabase.java | 3 +-- .../community/database/clickhouse/ClickHouseDatabaseType.java | 3 +-- .../community/database/clickhouse/ClickHouseParser.java | 3 +-- .../community/database/clickhouse/ClickHouseSchema.java | 3 +-- .../community/database/clickhouse/ClickHouseTable.java | 3 +-- 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConnection.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConnection.java index 4919312e8a..267d221ebc 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConnection.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConnection.java @@ -4,8 +4,7 @@ import java.sql.SQLException; -public class ClickHouseConnection extends Connection -{ +public class ClickHouseConnection extends Connection { ClickHouseConnection(ClickHouseDatabase database, java.sql.Connection connection) { super(database, connection); } diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java index b92a21ddd3..0630e0cf1f 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java @@ -9,8 +9,7 @@ import java.sql.Connection; -public class ClickHouseDatabase extends Database -{ +public class ClickHouseDatabase extends Database { @Override public boolean useSingleConnection() { return true; diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabaseType.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabaseType.java index 92c5e35b48..56fbfc6335 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabaseType.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabaseType.java @@ -10,8 +10,7 @@ import java.sql.Connection; -public class ClickHouseDatabaseType extends BaseDatabaseType -{ +public class ClickHouseDatabaseType extends BaseDatabaseType { @Override public String getName() { return "ClickHouse"; diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseParser.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseParser.java index 670a4d6355..d4055bf424 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseParser.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseParser.java @@ -4,8 +4,7 @@ import org.flywaydb.core.internal.parser.Parser; import org.flywaydb.core.internal.parser.ParsingContext; -public class ClickHouseParser extends Parser -{ +public class ClickHouseParser extends Parser { protected ClickHouseParser(Configuration configuration, ParsingContext parsingContext, int peekDepth) { super(configuration, parsingContext, peekDepth); } diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseSchema.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseSchema.java index fdbf27a9af..9dcd17330d 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseSchema.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseSchema.java @@ -5,8 +5,7 @@ import java.sql.SQLException; -public class ClickHouseSchema extends Schema -{ +public class ClickHouseSchema extends Schema { /** * @param jdbcTemplate The Jdbc Template for communicating with the DB. * @param database The database-specific support. diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java index c4409131a3..48301295ff 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java @@ -8,8 +8,7 @@ import java.sql.SQLException; @CustomLog -public class ClickHouseTable extends Table -{ +public class ClickHouseTable extends Table { /** * @param jdbcTemplate The JDBC template for communicating with the DB. * @param database The database-specific support. From 1c39e7b8d81a96cbefc0b6e0760d1c9670046342 Mon Sep 17 00:00:00 2001 From: Sergey Sazonov Date: Thu, 2 Mar 2023 18:45:24 +0300 Subject: [PATCH 10/20] JDBC driver update --- flyway-community-db-support/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flyway-community-db-support/pom.xml b/flyway-community-db-support/pom.xml index 3637e7210c..43933a513f 100644 --- a/flyway-community-db-support/pom.xml +++ b/flyway-community-db-support/pom.xml @@ -58,7 +58,7 @@ com.clickhouse clickhouse-jdbc - 0.4.0 + 0.4.1 true From 5b0b7cc9a0b1eb3496261bc74084910efe41775c Mon Sep 17 00:00:00 2001 From: Sergey Sazonov Date: Tue, 7 Mar 2023 15:35:25 +0300 Subject: [PATCH 11/20] Code-style --- flyway-community-db-support/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flyway-community-db-support/pom.xml b/flyway-community-db-support/pom.xml index 159af2c97c..d42979da96 100644 --- a/flyway-community-db-support/pom.xml +++ b/flyway-community-db-support/pom.xml @@ -151,4 +151,4 @@ - + \ No newline at end of file From 91031bd23840b394d93c3f71c76b5e0deb9a3899 Mon Sep 17 00:00:00 2001 From: Sergey Sazonov Date: Mon, 20 Mar 2023 10:38:56 +0300 Subject: [PATCH 12/20] User and pass detection by connection URL --- .../database/clickhouse/ClickHouseDatabaseType.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabaseType.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabaseType.java index 56fbfc6335..c9ff1f2fc3 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabaseType.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabaseType.java @@ -50,4 +50,14 @@ public ClickHouseDatabase createDatabase(Configuration configuration, JdbcConnec public Parser createParser(Configuration configuration, ResourceProvider resourceProvider, ParsingContext parsingContext) { return new ClickHouseParser(configuration, parsingContext, 3); } + + @Override + public boolean detectUserRequiredByUrl(String url) { + return !url.contains("user="); + } + + @Override + public boolean detectPasswordRequiredByUrl(String url) { + return !url.contains("password="); + } } From ade4e02179b46eb94fbef0006e4e0c99e740431d Mon Sep 17 00:00:00 2001 From: Sergey Sazonov Date: Tue, 21 Mar 2023 18:59:01 +0300 Subject: [PATCH 13/20] License and JDBC driver update, database product name check fix --- flyway-community-db-support/pom.xml | 4 ++-- .../ClickHouseConfigurationExtension.java | 15 +++++++++++++++ .../clickhouse/ClickHouseConnection.java | 15 +++++++++++++++ .../database/clickhouse/ClickHouseDatabase.java | 15 +++++++++++++++ .../clickhouse/ClickHouseDatabaseType.java | 17 ++++++++++++++++- .../database/clickhouse/ClickHouseParser.java | 15 +++++++++++++++ .../database/clickhouse/ClickHouseSchema.java | 15 +++++++++++++++ .../database/clickhouse/ClickHouseTable.java | 15 +++++++++++++++ 8 files changed, 108 insertions(+), 3 deletions(-) diff --git a/flyway-community-db-support/pom.xml b/flyway-community-db-support/pom.xml index 91b92bc0ae..6f51f8f387 100644 --- a/flyway-community-db-support/pom.xml +++ b/flyway-community-db-support/pom.xml @@ -58,7 +58,7 @@ com.clickhouse clickhouse-jdbc - 0.4.1 + 0.4.2 true @@ -151,4 +151,4 @@ - \ No newline at end of file + diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java index 7b523ea587..427e326d7e 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) Red Gate Software Ltd 2010-2022 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.flywaydb.community.database.clickhouse; import lombok.Getter; diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConnection.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConnection.java index 267d221ebc..87bf311837 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConnection.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConnection.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) Red Gate Software Ltd 2010-2022 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.flywaydb.community.database.clickhouse; import org.flywaydb.core.internal.database.base.Connection; diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java index 0630e0cf1f..e078e7519f 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) Red Gate Software Ltd 2010-2022 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.flywaydb.community.database.clickhouse; import org.flywaydb.core.api.configuration.Configuration; diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabaseType.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabaseType.java index c9ff1f2fc3..1fb3a02cf0 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabaseType.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabaseType.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) Red Gate Software Ltd 2010-2022 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.flywaydb.community.database.clickhouse; import org.flywaydb.core.api.ResourceProvider; @@ -38,7 +53,7 @@ public String getBackupDriverClass(String url, ClassLoader classLoader) { @Override public boolean handlesDatabaseProductNameAndVersion(String databaseProductName, String databaseProductVersion, Connection connection) { - return true; + return databaseProductName.startsWith("ClickHouse"); } @Override diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseParser.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseParser.java index d4055bf424..e9da2b2343 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseParser.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseParser.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) Red Gate Software Ltd 2010-2022 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.flywaydb.community.database.clickhouse; import org.flywaydb.core.api.configuration.Configuration; diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseSchema.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseSchema.java index 9dcd17330d..9556ce7aeb 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseSchema.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseSchema.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) Red Gate Software Ltd 2010-2022 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.flywaydb.community.database.clickhouse; import org.flywaydb.core.internal.database.base.Schema; diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java index 48301295ff..3bd10b67e8 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) Red Gate Software Ltd 2010-2022 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.flywaydb.community.database.clickhouse; import lombok.CustomLog; From 5f3f9d1acba68ba4db45ada732f65314755568c8 Mon Sep 17 00:00:00 2001 From: Sergey Sazonov Date: Tue, 21 Mar 2023 19:05:49 +0300 Subject: [PATCH 14/20] Code-style --- flyway-community-db-support/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flyway-community-db-support/pom.xml b/flyway-community-db-support/pom.xml index 6f51f8f387..32451aa468 100644 --- a/flyway-community-db-support/pom.xml +++ b/flyway-community-db-support/pom.xml @@ -151,4 +151,4 @@ - + \ No newline at end of file From cbc1d7a992e3f6fda895e07835c79c4f7577a31a Mon Sep 17 00:00:00 2001 From: Sergey Sazonov Date: Fri, 31 Mar 2023 16:53:54 +0300 Subject: [PATCH 15/20] Field 'version' is nullable again --- .../database/clickhouse/ClickHouseDatabase.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java index e078e7519f..f3114298a9 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java @@ -79,7 +79,7 @@ public String getRawCreateScript(Table table, boolean baseline) { String script = "CREATE TABLE IF NOT EXISTS " + table + (isClustered ? (" ON CLUSTER " + clusterName) : "") + "(" + " installed_rank Int32," + - " version String," + + " version Nullable(String)," + " description String," + " type String," + " script String," + @@ -90,14 +90,17 @@ public String getRawCreateScript(Table table, boolean baseline) { " success Bool" + ")"; + String engine; + if (isClustered) { - script += " ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/{database}/{table}', '{replica}')" + - " PARTITION BY tuple()" + - " ORDER BY (installed_rank);"; + engine = "ReplicatedMergeTree('/clickhouse/tables/{shard}/{database}/{table}', '{replica}')"; } else { - script += " ENGINE = MergeTree PRIMARY KEY (version);"; + engine = "MergeTree"; } + script += " ENGINE = " + engine + + " PRIMARY KEY (script);"; + return script + (baseline ? getBaselineStatement(table) + ";" : ""); } } From b8558a6ff823983f64b064c7bbb9ea90e2b1623e Mon Sep 17 00:00:00 2001 From: Sergey Sazonov Date: Mon, 14 Aug 2023 09:21:52 +0300 Subject: [PATCH 16/20] Configuration extension now supports getNamespace() method --- .../clickhouse/ClickHouseConfigurationExtension.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java index 427e326d7e..1bb1b61563 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java @@ -26,6 +26,11 @@ public class ClickHouseConfigurationExtension implements ConfigurationExtension private String clusterName; + @Override + public String getNamespace() { + return "clickhouse"; + } + @Override public void extractParametersFromConfiguration(Map configuration) { String clusterName = configuration.remove(CLUSTER_NAME); From ec813caa528e70f610c88642e994979fc6604a23 Mon Sep 17 00:00:00 2001 From: Sergey Sazonov Date: Mon, 14 Aug 2023 09:22:16 +0300 Subject: [PATCH 17/20] JDBC driver update --- flyway-community-db-support/pom.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/flyway-community-db-support/pom.xml b/flyway-community-db-support/pom.xml index f20bdb4404..ff31d9610f 100644 --- a/flyway-community-db-support/pom.xml +++ b/flyway-community-db-support/pom.xml @@ -58,8 +58,7 @@ com.clickhouse clickhouse-jdbc - 0.4.2 - true + 0.4.6 From c538eb190bc4e63ecd1abeda4f0a053f526ff438 Mon Sep 17 00:00:00 2001 From: Sergey Sazonov Date: Mon, 14 Aug 2023 10:39:59 +0300 Subject: [PATCH 18/20] Marked ClickHouse JDBC as optional dependency --- flyway-community-db-support/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/flyway-community-db-support/pom.xml b/flyway-community-db-support/pom.xml index e51e255803..4895546532 100644 --- a/flyway-community-db-support/pom.xml +++ b/flyway-community-db-support/pom.xml @@ -59,6 +59,7 @@ com.clickhouse clickhouse-jdbc 0.4.6 + true From 1cbb26ac2d18e3444ae48c0442c890955eb55e30 Mon Sep 17 00:00:00 2001 From: Sergey Sazonov Date: Mon, 11 Sep 2023 13:19:31 +0300 Subject: [PATCH 19/20] License update --- .../database/clickhouse/ClickHouseConfigurationExtension.java | 2 +- .../community/database/clickhouse/ClickHouseConnection.java | 2 +- .../community/database/clickhouse/ClickHouseDatabase.java | 2 +- .../community/database/clickhouse/ClickHouseDatabaseType.java | 2 +- .../community/database/clickhouse/ClickHouseParser.java | 2 +- .../community/database/clickhouse/ClickHouseSchema.java | 2 +- .../flywaydb/community/database/clickhouse/ClickHouseTable.java | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java index 1bb1b61563..ae076407ca 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java @@ -1,5 +1,5 @@ /* - * Copyright (C) Red Gate Software Ltd 2010-2022 + * Copyright (C) Red Gate Software Ltd 2010-2023 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConnection.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConnection.java index 87bf311837..230dd9a080 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConnection.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (C) Red Gate Software Ltd 2010-2022 + * Copyright (C) Red Gate Software Ltd 2010-2023 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java index f3114298a9..c8695b2f6e 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java @@ -1,5 +1,5 @@ /* - * Copyright (C) Red Gate Software Ltd 2010-2022 + * Copyright (C) Red Gate Software Ltd 2010-2023 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabaseType.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabaseType.java index 1fb3a02cf0..1f940b0e09 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabaseType.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabaseType.java @@ -1,5 +1,5 @@ /* - * Copyright (C) Red Gate Software Ltd 2010-2022 + * Copyright (C) Red Gate Software Ltd 2010-2023 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseParser.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseParser.java index e9da2b2343..3d4532bf55 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseParser.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseParser.java @@ -1,5 +1,5 @@ /* - * Copyright (C) Red Gate Software Ltd 2010-2022 + * Copyright (C) Red Gate Software Ltd 2010-2023 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseSchema.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseSchema.java index 9556ce7aeb..e1fbcafef4 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseSchema.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseSchema.java @@ -1,5 +1,5 @@ /* - * Copyright (C) Red Gate Software Ltd 2010-2022 + * Copyright (C) Red Gate Software Ltd 2010-2023 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java index 3bd10b67e8..40c18e43b1 100644 --- a/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java +++ b/flyway-community-db-support/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java @@ -1,5 +1,5 @@ /* - * Copyright (C) Red Gate Software Ltd 2010-2022 + * Copyright (C) Red Gate Software Ltd 2010-2023 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 9e9046396d1b9f940ca6d7f7f760a9d24e2e6cb1 Mon Sep 17 00:00:00 2001 From: Sergey Sazonov Date: Wed, 1 Nov 2023 19:09:54 +0300 Subject: [PATCH 20/20] Flyway 10 support --- flyway-commandline/pom.xml | 8 ++- .../src/main/assembly/component.xml | 3 +- .../flyway-database-clickhouse/pom.xml | 66 +++++++++++++++++++ .../database/ClickHouseDatabaseExtension.java | 39 +++++++++++ .../ClickHouseConfigurationExtension.java | 0 .../clickhouse/ClickHouseConnection.java | 3 +- .../clickhouse/ClickHouseDatabase.java | 2 +- .../clickhouse/ClickHouseDatabaseType.java | 0 .../clickhouse/ClickHouseParser.java | 0 .../clickhouse/ClickHouseSchema.java | 0 .../database}/clickhouse/ClickHouseTable.java | 0 .../org.flywaydb.core.extensibility.Plugin | 2 + .../community/database/clickhouse/version.txt | 1 + flyway-community-db-support/pom.xml | 1 + 14 files changed, 121 insertions(+), 4 deletions(-) create mode 100644 flyway-community-db-support/flyway-database-clickhouse/pom.xml create mode 100644 flyway-community-db-support/flyway-database-clickhouse/src/main/java/org/flywaydb/community/database/ClickHouseDatabaseExtension.java rename flyway-community-db-support/{flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql => flyway-database-clickhouse/src/main/java/org/flywaydb/community/database}/clickhouse/ClickHouseConfigurationExtension.java (100%) rename flyway-community-db-support/{flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql => flyway-database-clickhouse/src/main/java/org/flywaydb/community/database}/clickhouse/ClickHouseConnection.java (90%) rename flyway-community-db-support/{flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql => flyway-database-clickhouse/src/main/java/org/flywaydb/community/database}/clickhouse/ClickHouseDatabase.java (98%) rename flyway-community-db-support/{flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql => flyway-database-clickhouse/src/main/java/org/flywaydb/community/database}/clickhouse/ClickHouseDatabaseType.java (100%) rename flyway-community-db-support/{flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql => flyway-database-clickhouse/src/main/java/org/flywaydb/community/database}/clickhouse/ClickHouseParser.java (100%) rename flyway-community-db-support/{flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql => flyway-database-clickhouse/src/main/java/org/flywaydb/community/database}/clickhouse/ClickHouseSchema.java (100%) rename flyway-community-db-support/{flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql => flyway-database-clickhouse/src/main/java/org/flywaydb/community/database}/clickhouse/ClickHouseTable.java (100%) create mode 100644 flyway-community-db-support/flyway-database-clickhouse/src/main/resources/META-INF/services/org.flywaydb.core.extensibility.Plugin create mode 100644 flyway-community-db-support/flyway-database-clickhouse/src/main/resources/org/flywaydb/community/database/clickhouse/version.txt diff --git a/flyway-commandline/pom.xml b/flyway-commandline/pom.xml index 27c39c1479..a9427047b6 100644 --- a/flyway-commandline/pom.xml +++ b/flyway-commandline/pom.xml @@ -153,6 +153,12 @@ ${project.version} runtime + + ${project.groupId} + flyway-database-clickhouse + ${project.version} + runtime + @@ -1078,4 +1084,4 @@ - \ No newline at end of file + diff --git a/flyway-commandline/src/main/assembly/component.xml b/flyway-commandline/src/main/assembly/component.xml index 6bec848e32..3697e0ce19 100644 --- a/flyway-commandline/src/main/assembly/component.xml +++ b/flyway-commandline/src/main/assembly/component.xml @@ -199,6 +199,7 @@ org.flywaydb:flyway-database-ignite org.flywaydb:flyway-database-tidb org.flywaydb:flyway-database-yugabytedb + org.flywaydb:flyway-database-clickhouse org.flywaydb:flyway-sqlserver org.flywaydb:flyway-singlestore org.flywaydb:flyway-mysql @@ -249,4 +250,4 @@ - \ No newline at end of file + diff --git a/flyway-community-db-support/flyway-database-clickhouse/pom.xml b/flyway-community-db-support/flyway-database-clickhouse/pom.xml new file mode 100644 index 0000000000..5029d047f8 --- /dev/null +++ b/flyway-community-db-support/flyway-database-clickhouse/pom.xml @@ -0,0 +1,66 @@ + + + + 4.0.0 + + org.flywaydb + flyway-community-db-support + 10.0.0 + + + flyway-database-clickhouse + ${project.artifactId} + + + + ${project.groupId} + flyway-core + + + org.projectlombok + lombok + provided + + + com.clickhouse + clickhouse-jdbc + 0.5.0 + true + + + + + + + src/main/resources + true + + + + + maven-resources-plugin + + + maven-jar-plugin + + + + diff --git a/flyway-community-db-support/flyway-database-clickhouse/src/main/java/org/flywaydb/community/database/ClickHouseDatabaseExtension.java b/flyway-community-db-support/flyway-database-clickhouse/src/main/java/org/flywaydb/community/database/ClickHouseDatabaseExtension.java new file mode 100644 index 0000000000..406c3229e9 --- /dev/null +++ b/flyway-community-db-support/flyway-database-clickhouse/src/main/java/org/flywaydb/community/database/ClickHouseDatabaseExtension.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) Red Gate Software Ltd 2010-2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.flywaydb.community.database; + +import org.flywaydb.core.api.FlywayException; +import org.flywaydb.core.extensibility.PluginMetadata; +import org.flywaydb.core.internal.util.FileUtils; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; + +public class ClickHouseDatabaseExtension implements PluginMetadata { + public String getDescription() { + return "Community-contributed Ignite database support extension " + readVersion() + " by Redgate"; + } + + private static String readVersion() { + try { + return FileUtils.copyToString( + ClickHouseDatabaseExtension.class.getClassLoader().getResourceAsStream("org/flywaydb/community/database/clickhouse/version.txt"), + StandardCharsets.UTF_8); + } catch (IOException e) { + throw new FlywayException("Unable to read extension version: " + e.getMessage(), e); + } + } +} diff --git a/flyway-community-db-support/flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql/clickhouse/ClickHouseConfigurationExtension.java b/flyway-community-db-support/flyway-database-clickhouse/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java similarity index 100% rename from flyway-community-db-support/flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql/clickhouse/ClickHouseConfigurationExtension.java rename to flyway-community-db-support/flyway-database-clickhouse/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConfigurationExtension.java diff --git a/flyway-community-db-support/flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql/clickhouse/ClickHouseConnection.java b/flyway-community-db-support/flyway-database-clickhouse/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConnection.java similarity index 90% rename from flyway-community-db-support/flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql/clickhouse/ClickHouseConnection.java rename to flyway-community-db-support/flyway-database-clickhouse/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConnection.java index 230dd9a080..d3ebd1e25f 100644 --- a/flyway-community-db-support/flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql/clickhouse/ClickHouseConnection.java +++ b/flyway-community-db-support/flyway-database-clickhouse/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseConnection.java @@ -18,6 +18,7 @@ import org.flywaydb.core.internal.database.base.Connection; import java.sql.SQLException; +import java.util.Optional; public class ClickHouseConnection extends Connection { ClickHouseConnection(ClickHouseDatabase database, java.sql.Connection connection) { @@ -26,7 +27,7 @@ public class ClickHouseConnection extends Connection { @Override protected String getCurrentSchemaNameOrSearchPath() throws SQLException { - return database.unQuote(getJdbcTemplate().getConnection().getSchema()); + return Optional.ofNullable(getJdbcTemplate().getConnection().getSchema()).map(database::unQuote).orElse(null); } @Override diff --git a/flyway-community-db-support/flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql/clickhouse/ClickHouseDatabase.java b/flyway-community-db-support/flyway-database-clickhouse/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java similarity index 98% rename from flyway-community-db-support/flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql/clickhouse/ClickHouseDatabase.java rename to flyway-community-db-support/flyway-database-clickhouse/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java index c8695b2f6e..4afafddda0 100644 --- a/flyway-community-db-support/flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql/clickhouse/ClickHouseDatabase.java +++ b/flyway-community-db-support/flyway-database-clickhouse/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabase.java @@ -44,7 +44,7 @@ protected ClickHouseConnection doGetConnection(Connection connection) { } @Override - public void ensureSupported() { + public void ensureSupported(Configuration configuration) { } @Override diff --git a/flyway-community-db-support/flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql/clickhouse/ClickHouseDatabaseType.java b/flyway-community-db-support/flyway-database-clickhouse/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabaseType.java similarity index 100% rename from flyway-community-db-support/flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql/clickhouse/ClickHouseDatabaseType.java rename to flyway-community-db-support/flyway-database-clickhouse/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseDatabaseType.java diff --git a/flyway-community-db-support/flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql/clickhouse/ClickHouseParser.java b/flyway-community-db-support/flyway-database-clickhouse/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseParser.java similarity index 100% rename from flyway-community-db-support/flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql/clickhouse/ClickHouseParser.java rename to flyway-community-db-support/flyway-database-clickhouse/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseParser.java diff --git a/flyway-community-db-support/flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql/clickhouse/ClickHouseSchema.java b/flyway-community-db-support/flyway-database-clickhouse/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseSchema.java similarity index 100% rename from flyway-community-db-support/flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql/clickhouse/ClickHouseSchema.java rename to flyway-community-db-support/flyway-database-clickhouse/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseSchema.java diff --git a/flyway-community-db-support/flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql/clickhouse/ClickHouseTable.java b/flyway-community-db-support/flyway-database-clickhouse/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java similarity index 100% rename from flyway-community-db-support/flyway-database-yugabytedb/src/main/java/org/flywaydb/community/database/postgresql/clickhouse/ClickHouseTable.java rename to flyway-community-db-support/flyway-database-clickhouse/src/main/java/org/flywaydb/community/database/clickhouse/ClickHouseTable.java diff --git a/flyway-community-db-support/flyway-database-clickhouse/src/main/resources/META-INF/services/org.flywaydb.core.extensibility.Plugin b/flyway-community-db-support/flyway-database-clickhouse/src/main/resources/META-INF/services/org.flywaydb.core.extensibility.Plugin new file mode 100644 index 0000000000..628c219f16 --- /dev/null +++ b/flyway-community-db-support/flyway-database-clickhouse/src/main/resources/META-INF/services/org.flywaydb.core.extensibility.Plugin @@ -0,0 +1,2 @@ +org.flywaydb.community.database.clickhouse.ClickHouseConfigurationExtension +org.flywaydb.community.database.clickhouse.ClickHouseDatabaseType diff --git a/flyway-community-db-support/flyway-database-clickhouse/src/main/resources/org/flywaydb/community/database/clickhouse/version.txt b/flyway-community-db-support/flyway-database-clickhouse/src/main/resources/org/flywaydb/community/database/clickhouse/version.txt new file mode 100644 index 0000000000..17851514a7 --- /dev/null +++ b/flyway-community-db-support/flyway-database-clickhouse/src/main/resources/org/flywaydb/community/database/clickhouse/version.txt @@ -0,0 +1 @@ +${pom.version} \ No newline at end of file diff --git a/flyway-community-db-support/pom.xml b/flyway-community-db-support/pom.xml index 5f6ea50783..83f5afe77d 100644 --- a/flyway-community-db-support/pom.xml +++ b/flyway-community-db-support/pom.xml @@ -33,6 +33,7 @@ flyway-database-tidb flyway-database-ignite flyway-database-yugabytedb + flyway-database-clickhouse