Fixes after merge remote-tracking branch 'remotes/open/master' into szymonsztuka/os-merge-20180824

This commit is contained in:
szymonsztuka
2018-08-24 12:27:47 +01:00
parent 598e3a327a
commit c7f666102f
11 changed files with 32 additions and 39 deletions

View File

@ -63,11 +63,6 @@ dependencies {
// For caches rather than guava
compile "com.github.ben-manes.caffeine:caffeine:$caffeine_version"
// For db migration
compile "org.liquibase:liquibase-core:$liquibase_version"
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
runtime 'com.mattbertolini:liquibase-slf4j:2.0.0'
// Unit testing helpers.
testCompile "junit:junit:$junit_version"
testCompile "org.assertj:assertj-core:$assertj_version"

View File

@ -34,7 +34,7 @@ object MigrationHelpers {
}
// SchemaName will be transformed from camel case to lower_hyphen then add ".changelog-master"
private fun migrationResourceNameForSchema(schema: MappedSchema): String {
fun migrationResourceNameForSchema(schema: MappedSchema): String {
val name: String = schema::class.simpleName!!
val fileName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, name)
return "$MIGRATION_PREFIX/$fileName.$CHANGELOG_NAME"

View File

@ -42,13 +42,13 @@ class SchemaMigration(
* Main entry point to the schema migration.
* Called during node startup.
*/
fun nodeStartup(existingCheckpoints: Boolean) {
fun nodeStartup(existingCheckpoints: Boolean, isH2Database: Boolean) {
when {
databaseConfig.initialiseSchema -> {
//TODO if it's h2 only
databaseConfig.initialiseSchema && isH2Database -> {
migrateOlderDatabaseToUseLiquibase(existingCheckpoints)
runMigration(existingCheckpoints)
}
databaseConfig.initialiseSchema -> runMigration(existingCheckpoints)
else -> checkState()
}
}
@ -66,7 +66,7 @@ class SchemaMigration(
/**
* Ensures that the database is up to date with the latest migration changes.
*/
private fun checkState() = doRunMigration(run = false, outputWriter = null, check = true)
fun checkState() = doRunMigration(run = false, outputWriter = null, check = true)
/**
* Can be used from an external tool to release the lock in case something went terribly wrong.
@ -138,7 +138,6 @@ class SchemaMigration(
check && !run && unRunChanges.isNotEmpty() -> throw OutstandingDatabaseChangesException(unRunChanges.size)
check && !run -> {} // Do nothing will be interpreted as "check succeeded"
(outputWriter != null) && !check && !run -> liquibase.update(Contexts(), outputWriter)
(outputWriter != null) && !check && !run -> liquibase.update(Contexts(), outputWriter)
else -> throw IllegalStateException("Invalid usage.")
}
}