Skip to content

Commit

Permalink
Flyway 10 support
Browse files Browse the repository at this point in the history
  • Loading branch information
sazonov committed Nov 2, 2023
1 parent c7f4690 commit 9e90463
Show file tree
Hide file tree
Showing 14 changed files with 121 additions and 4 deletions.
8 changes: 7 additions & 1 deletion flyway-commandline/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>flyway-database-clickhouse</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>



Expand Down Expand Up @@ -1078,4 +1084,4 @@
</profile>

</profiles>
</project>
</project>
3 changes: 2 additions & 1 deletion flyway-commandline/src/main/assembly/component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@
<include>org.flywaydb:flyway-database-ignite</include>
<include>org.flywaydb:flyway-database-tidb</include>
<include>org.flywaydb:flyway-database-yugabytedb</include>
<include>org.flywaydb:flyway-database-clickhouse</include>
<include>org.flywaydb:flyway-sqlserver</include>
<include>org.flywaydb:flyway-singlestore</include>
<include>org.flywaydb:flyway-mysql</include>
Expand Down Expand Up @@ -249,4 +250,4 @@
</excludes>
</dependencySet>
</dependencySets>
</component>
</component>
66 changes: 66 additions & 0 deletions flyway-community-db-support/flyway-database-clickhouse/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<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>
<parent>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-community-db-support</artifactId>
<version>10.0.0</version>
</parent>

<artifactId>flyway-database-clickhouse</artifactId>
<name>${project.artifactId}</name>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.clickhouse</groupId>
<artifactId>clickhouse-jdbc</artifactId>
<version>0.5.0</version>
<optional>true</optional>
</dependency>
</dependencies>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<ClickHouseDatabase> {
ClickHouseConnection(ClickHouseDatabase database, java.sql.Connection connection) {
Expand All @@ -26,7 +27,7 @@ public class ClickHouseConnection extends Connection<ClickHouseDatabase> {

@Override
protected String getCurrentSchemaNameOrSearchPath() throws SQLException {
return database.unQuote(getJdbcTemplate().getConnection().getSchema());
return Optional.ofNullable(getJdbcTemplate().getConnection().getSchema()).map(database::unQuote).orElse(null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected ClickHouseConnection doGetConnection(Connection connection) {
}

@Override
public void ensureSupported() {
public void ensureSupported(Configuration configuration) {
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
org.flywaydb.community.database.clickhouse.ClickHouseConfigurationExtension
org.flywaydb.community.database.clickhouse.ClickHouseDatabaseType
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${pom.version}
1 change: 1 addition & 0 deletions flyway-community-db-support/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<module>flyway-database-tidb</module>
<module>flyway-database-ignite</module>
<module>flyway-database-yugabytedb</module>
<module>flyway-database-clickhouse</module>
</modules>

<dependencyManagement>
Expand Down

0 comments on commit 9e90463

Please sign in to comment.