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