mirror of
https://github.com/corda/corda.git
synced 2025-02-06 02:59:15 +00:00
Fix null migration resource (#210)
throw exception when migration not set for MappedSchema
This commit is contained in:
parent
3ab1a06db6
commit
dd59b06c62
@ -46,7 +46,8 @@ open class MappedSchema(schemaFamily: Class<*>,
|
|||||||
* Points to a classpath resource containing the database changes for the [mappedTypes]
|
* Points to a classpath resource containing the database changes for the [mappedTypes]
|
||||||
*/
|
*/
|
||||||
protected open val migrationResource: String? = null
|
protected open val migrationResource: String? = null
|
||||||
internal fun getMigrationResource(): String = migrationResource!!
|
|
||||||
|
internal fun getMigrationResource(): String = migrationResource ?: throw IllegalStateException("Migration resource not set for schema $this")
|
||||||
|
|
||||||
override fun toString(): String = "${this.javaClass.simpleName}(name=$name, version=$version)"
|
override fun toString(): String = "${this.javaClass.simpleName}(name=$name, version=$version)"
|
||||||
}
|
}
|
||||||
|
@ -28,11 +28,6 @@ class SchemaMigration(val schemas: Set<MappedSchema>, val dataSource: DataSource
|
|||||||
|
|
||||||
dataSource.connection.use { connection ->
|
dataSource.connection.use { connection ->
|
||||||
|
|
||||||
//create a resourse accessor that aggregates the changelogs included in the schemas into one dynamic stream
|
|
||||||
val customResourceAccessor = object : ClassLoaderResourceAccessor() {
|
|
||||||
override fun getResourcesAsStream(path: String): Set<InputStream> {
|
|
||||||
|
|
||||||
if (path == dynamicInclude) {
|
|
||||||
//collect all changelog file referenced in the included schemas
|
//collect all changelog file referenced in the included schemas
|
||||||
val changelogList = schemas.map { mappedSchema ->
|
val changelogList = schemas.map { mappedSchema ->
|
||||||
getMigrationResource(mappedSchema).let {
|
getMigrationResource(mappedSchema).let {
|
||||||
@ -40,6 +35,11 @@ class SchemaMigration(val schemas: Set<MappedSchema>, val dataSource: DataSource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//create a resourse accessor that aggregates the changelogs included in the schemas into one dynamic stream
|
||||||
|
val customResourceAccessor = object : ClassLoaderResourceAccessor() {
|
||||||
|
override fun getResourcesAsStream(path: String): Set<InputStream> {
|
||||||
|
|
||||||
|
if (path == dynamicInclude) {
|
||||||
//create a map in liquibase format including all migration files
|
//create a map in liquibase format including all migration files
|
||||||
val includeAllFiles = mapOf("databaseChangeLog" to changelogList.map { file -> mapOf("include" to mapOf("file" to file)) })
|
val includeAllFiles = mapOf("databaseChangeLog" to changelogList.map { file -> mapOf("include" to mapOf("file" to file)) })
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user