diff --git a/server/src/main/kotlin/tech/figure/objectstore/gateway/configuration/AppProperties.kt b/server/src/main/kotlin/tech/figure/objectstore/gateway/configuration/AppProperties.kt index 36f62f5..fe64369 100644 --- a/server/src/main/kotlin/tech/figure/objectstore/gateway/configuration/AppProperties.kt +++ b/server/src/main/kotlin/tech/figure/objectstore/gateway/configuration/AppProperties.kt @@ -52,6 +52,6 @@ data class DatabaseProperties( val port: String, val schema: String, @Pattern(value = "\\d{1,2}") val connectionPoolSize: String, - val baselineOnMigrate: Boolean, - val repairFlywayChecksums: Boolean, + val baselineOnMigrate: Boolean = false, + val repairFlywayChecksums: Boolean = false, ) diff --git a/server/src/main/kotlin/tech/figure/objectstore/gateway/configuration/DataConfig.kt b/server/src/main/kotlin/tech/figure/objectstore/gateway/configuration/DataConfig.kt index 309f857..8f38f95 100644 --- a/server/src/main/kotlin/tech/figure/objectstore/gateway/configuration/DataConfig.kt +++ b/server/src/main/kotlin/tech/figure/objectstore/gateway/configuration/DataConfig.kt @@ -85,6 +85,10 @@ class DataConfig { if (databaseProperties.type != "postgresql") { baseline() } + if (databaseProperties.repairFlywayChecksums) { + logger.warn("Flyway checksum repair has been requested! This should only be enabled temporarily. Set db.repairFlywayChecks=false or omit the value ASAP") + repair() + } } @Bean @@ -92,10 +96,6 @@ class DataConfig { @Bean("MigrationsExecuted") fun flywayMigration(dataSource: DataSource, databaseProperties: DatabaseProperties, flyway: Flyway): Int { - if (databaseProperties.repairFlywayChecksums) { - logger.warn("Flyway checksum repair has been requested! This should only be enabled temporarily. Set db.repairFlywayChecks=false or omit the value ASAP") - flyway.repair() - } flyway.info().all().forEach { logger.info("Flyway migration: ${it.script}") } return flyway.migrate().migrationsExecuted } diff --git a/server/src/test/kotlin/tech/figure/objectstore/gateway/db/MemoryMigrationsTest.kt b/server/src/test/kotlin/tech/figure/objectstore/gateway/db/MemoryMigrationsTest.kt index e942b4f..3f967db 100644 --- a/server/src/test/kotlin/tech/figure/objectstore/gateway/db/MemoryMigrationsTest.kt +++ b/server/src/test/kotlin/tech/figure/objectstore/gateway/db/MemoryMigrationsTest.kt @@ -22,7 +22,6 @@ class MemoryMigrationsTest { schema = "object-store-gateway", connectionPoolSize = "1", baselineOnMigrate = false, - repairFlywayChecksums = false, ) DbMigrationTester(properties).removeDatabaseTables().testMigrations() } diff --git a/server/src/test/kotlin/tech/figure/objectstore/gateway/db/PostgresqlMigrationsTest.kt b/server/src/test/kotlin/tech/figure/objectstore/gateway/db/PostgresqlMigrationsTest.kt index 7cd39b4..abbd3ce 100644 --- a/server/src/test/kotlin/tech/figure/objectstore/gateway/db/PostgresqlMigrationsTest.kt +++ b/server/src/test/kotlin/tech/figure/objectstore/gateway/db/PostgresqlMigrationsTest.kt @@ -61,6 +61,5 @@ class PostgresqlMigrationsTest { schema = "object-store-gateway", connectionPoolSize = "1", baselineOnMigrate = false, - repairFlywayChecksums = false, ) } diff --git a/server/src/test/kotlin/tech/figure/objectstore/gateway/db/SqliteMigrationsTest.kt b/server/src/test/kotlin/tech/figure/objectstore/gateway/db/SqliteMigrationsTest.kt index e59bbc8..0e48bcd 100644 --- a/server/src/test/kotlin/tech/figure/objectstore/gateway/db/SqliteMigrationsTest.kt +++ b/server/src/test/kotlin/tech/figure/objectstore/gateway/db/SqliteMigrationsTest.kt @@ -19,7 +19,6 @@ class SqliteMigrationsTest { schema = "object-store-gateway", connectionPoolSize = "1", baselineOnMigrate = false, - repairFlywayChecksums = false, ) DbMigrationTester(properties).testMigrations() } diff --git a/server/src/test/resources/application.properties b/server/src/test/resources/application.properties index dd9a44c..6212a24 100644 --- a/server/src/test/resources/application.properties +++ b/server/src/test/resources/application.properties @@ -25,4 +25,3 @@ db.port="" db.schema=object-store-gateway db.connectionPoolSize=1 db.baselineOnMigrate=true -db.repairFlywayChecksums=false