flyway / flyway-community-db-support

Offical Flyway Community Supported Database Plugins
https://flywaydb.org/
Apache License 2.0
5 stars 30 forks source link

Clickhouse fixes for cluster operation #17

Closed Chris3LC closed 8 months ago

Chris3LC commented 8 months ago

I tried to make the clickhouse community plugin work on our setup, but had to make a few changes:

Each change is in a separate commit.

Chris3LC commented 8 months ago

@sazonov Could you please review this change?

This is approximately the setup we used to run it (kotlin):

    Flyway(
        Flyway.configure()
            .dataSource(
                "jdbc:clickhouse://localhost:9001/", // change port to 9002, 9003, 9004 for the other nodes of the cluster
                "admin",
                "123"
            )
            .configuration(mapOf(
                "flyway.clickhouse.clusterName" to "'{cluster}'",
                // don't put {shard} in the zookeeperPath, to have the change replicated (and visible) on all nodes
                "flyway.clickhouse.zookeeperPath" to "/clickhouse/tables/{database}/{table}",
            ))
            .placeholders(mapOf("database" to "the_database"))
            .schemas("the_database")
            .createSchemas(true)
            .failOnMissingLocations(true)
            .locations("clickhouse/migrations")
            .table("flyway_history")
            .baselineVersion("0000")
            .baselineOnMigrate(true)
    ).migrate()

I tested using following docker-compose cluster: https://github.com/Chris3LC/clickhouse-cluster

sazonov commented 8 months ago

@Barry-RG those are critical fixes.