CORDA-3302: Align OS + Ent SchemaMigration parameters (#5622)

* Rename SchemaMigrationTest and make ourName parameter nullable to remove enterprise conflicts

* Fix detekt baseline

* Further alignment

* Update detekt
This commit is contained in:
Anthony Keenan
2019-10-24 18:54:35 +01:00
committed by GitHub
parent 6493ffefef
commit 6e43bc1db6
3 changed files with 14 additions and 11 deletions

View File

@ -31,7 +31,7 @@ class SchemaMigration(
// This parameter is used by the vault state migration to establish what the node's legal identity is when setting up
// its copy of the identity service. It is passed through using a system property. When multiple identity support is added, this will need
// reworking so that multiple identities can be passed to the migration.
private val ourName: CordaX500Name,
private val ourName: CordaX500Name? = null,
// This parameter forces an error to be thrown if there are missing migrations. When using H2, Hibernate will automatically create schemas where they are
// missing, so no need to throw unless you're specifically testing whether all the migrations are present.
private val forceThrowOnMissingMigration: Boolean = false) {
@ -99,7 +99,11 @@ class SchemaMigration(
null
}
private fun doRunMigration(run: Boolean, check: Boolean, existingCheckpoints: Boolean? = null) {
private fun doRunMigration(
run: Boolean,
check: Boolean,
existingCheckpoints: Boolean? = null
) {
// Virtual file name of the changelog that includes all schemas.
val dynamicInclude = "master.changelog.json"
@ -121,7 +125,9 @@ class SchemaMigration(
if (path != null) {
System.setProperty(NODE_BASE_DIR_KEY, path) // base dir for any custom change set which may need to load a file (currently AttachmentVersionNumberMigration)
}
System.setProperty(NODE_X500_NAME, ourName.toString())
if (ourName != null) {
System.setProperty(NODE_X500_NAME, ourName.toString())
}
val customResourceAccessor = CustomResourceAccessor(dynamicInclude, changelogList, classLoader)
checkResourcesInClassPath(changelogList)

View File

@ -1,13 +1,10 @@
package net.corda.nodeapi.internal
package net.corda.nodeapi.internal.persistence
import net.corda.core.schemas.MappedSchema
import net.corda.core.schemas.PersistentState
import net.corda.node.internal.DataSourceFactory
import net.corda.node.services.persistence.DBCheckpointStorage
import net.corda.node.services.schema.NodeSchemaService
import net.corda.nodeapi.internal.persistence.DatabaseConfig
import net.corda.nodeapi.internal.persistence.MissingMigrationException
import net.corda.nodeapi.internal.persistence.SchemaMigration
import net.corda.testing.core.ALICE_NAME
import net.corda.testing.core.TestIdentity
import net.corda.testing.node.MockServices
@ -20,7 +17,7 @@ import javax.persistence.Column
import javax.persistence.Entity
import javax.sql.DataSource
class SchemaMigrationTest {
class MissingSchemaMigrationTest {
object TestSchemaFamily
object GoodSchema : MappedSchema(schemaFamily = TestSchemaFamily.javaClass, version = 1, mappedTypes = listOf(State::class.java)) {