diff --git a/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/migration/CertificateDataSerialNumber.kt b/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/migration/CertificateDataSerialNumber.kt deleted file mode 100644 index 6751840aa8..0000000000 --- a/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/migration/CertificateDataSerialNumber.kt +++ /dev/null @@ -1,49 +0,0 @@ -package com.r3.corda.networkmanage.common.persistence.migration - -import com.r3.corda.networkmanage.common.utils.buildCertPath -import liquibase.change.custom.CustomTaskChange -import liquibase.database.Database -import liquibase.database.jvm.JdbcConnection -import liquibase.exception.ValidationErrors -import liquibase.resource.ResourceAccessor -import org.bouncycastle.jce.provider.BouncyCastleProvider -import java.math.BigDecimal -import java.security.Security -import java.security.cert.X509Certificate -import java.sql.ResultSet - -class CertificateDataSerialNumber : CustomTaskChange { - override fun validate(database: Database?): ValidationErrors? { - return null - } - - override fun setUp() { - // Do nothing - } - - override fun setFileOpener(resourceAccessor: ResourceAccessor?) { - // Do nothing - } - - override fun getConfirmationMessage(): String { - return "Certificate data serial numbers have been extracted and persisted." - } - - override fun execute(database: Database?) { - Security.addProvider(BouncyCastleProvider()) - val jdbcConnection = database!!.connection as JdbcConnection - jdbcConnection.autoCommit = true - val statement = jdbcConnection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE) - val resultSet = statement.executeQuery("SELECT certificate_path_bytes, certificate_serial_number FROM certificate_data") - while (resultSet.next()) { - val blob = resultSet.getBlob(1) - val certPath = buildCertPath(blob.getBytes(1, blob.length().toInt())) - blob.free() - val serialNumber = (certPath.certificates.first() as X509Certificate).serialNumber - resultSet.updateBigDecimal(2, BigDecimal(serialNumber)) - resultSet.updateRow() - } - statement.close() - } - -} \ No newline at end of file diff --git a/network-management/src/main/resources/migration/README.md b/network-management/src/main/resources/migration/README.md new file mode 100644 index 0000000000..255c13c59a --- /dev/null +++ b/network-management/src/main/resources/migration/README.md @@ -0,0 +1,17 @@ +#How to generate change log xml from database + +* Download liquidBase binary from[here](http://download.liquibase.org) +* Download H2 driver from[here](http://www.h2database.com/html/download.html) +* Generate a H2 database by starting the network map server (can be done using one of the integration test). + +Run the following command to generate change log XML. +``` +java -jar liquibase.jar --driver=org.h2.Driver \ +--classpath=h2-1.4.196.jar \ +--changeLogFile=network-manager.changelog.xml \ +--url="jdbc:h2:file:./networkMap" \ +--username=sa \ +--password= \ +generateChangeLog +``` +TODO : This instruction is only for initial changelog generation, remove this after R3C v3. \ No newline at end of file diff --git a/network-management/src/main/resources/migration/network-manager.changelog-adding-crr.xml b/network-management/src/main/resources/migration/network-manager.changelog-adding-crr.xml deleted file mode 100644 index 928b67ffa6..0000000000 --- a/network-management/src/main/resources/migration/network-manager.changelog-adding-crr.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/network-management/src/main/resources/migration/network-manager.changelog-init.xml b/network-management/src/main/resources/migration/network-manager.changelog-init.xml index 140358f900..5c6e68f17c 100644 --- a/network-management/src/main/resources/migration/network-manager.changelog-init.xml +++ b/network-management/src/main/resources/migration/network-manager.changelog-init.xml @@ -9,7 +9,9 @@ ~ Distribution of this file or any portion thereof via any medium without the express permission of R3 is strictly prohibited. --> - + @@ -22,42 +24,20 @@ - - - - - - - - - - - - - - - - - - - - - - - + - + - + - + @@ -72,26 +52,29 @@ - + + + - + - + - + - + + - + @@ -101,16 +84,18 @@ - + - + - - + + + + - + @@ -121,86 +106,142 @@ - + - - + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - + + + + + + + + + - - - - - - - + + - - + + - - - - - + - + - - + + - - + + + + + + + + + + + + diff --git a/network-management/src/main/resources/migration/network-manager.changelog-master.xml b/network-management/src/main/resources/migration/network-manager.changelog-master.xml index 7be4d3c3a9..7ff18a526c 100644 --- a/network-management/src/main/resources/migration/network-manager.changelog-master.xml +++ b/network-management/src/main/resources/migration/network-manager.changelog-master.xml @@ -9,12 +9,8 @@ ~ Distribution of this file or any portion thereof via any medium without the express permission of R3 is strictly prohibited. --> - - + - - - - - diff --git a/network-management/src/main/resources/migration/network-manager.changelog-modified-by-refactor.xml b/network-management/src/main/resources/migration/network-manager.changelog-modified-by-refactor.xml deleted file mode 100644 index 132abe2109..0000000000 --- a/network-management/src/main/resources/migration/network-manager.changelog-modified-by-refactor.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - status = 'SIGNED' - - - - status = 'SIGNED' - - - - - - - - - - - - - - - - UPDATE - csr_a - SET - csr_a.modified_by = csr_mb_a.modified_by - FROM - certificate_signing_request_AUD AS csr_a - INNER JOIN CertificateSigningRequestEntity_modifiedBy_AUD AS csr_mb_a - ON csr_a.rev = csr_mb_a.rev - WHERE - csr_mb_a.revtype = 0 - - - - - UPDATE - certificate_signing_request_AUD as csr_a - SET - (csr_a.modified_by) = (SELECT csr_mb_a.modified_by - FROM - certificate_signing_request_AUD AS csr_a - INNER JOIN CertificateSigningRequestEntity_modifiedBy_AUD AS csr_mb_a - ON csr_a.rev = csr_mb_a.rev - WHERE - csr_mb_a.revtype = 0) - - - - - - - - - \ No newline at end of file diff --git a/network-management/src/main/resources/migration/network-manager.changelog-pub-key-move.xml b/network-management/src/main/resources/migration/network-manager.changelog-pub-key-move.xml deleted file mode 100644 index f52c058531..0000000000 --- a/network-management/src/main/resources/migration/network-manager.changelog-pub-key-move.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/network-management/src/main/resources/migration/network-manager.changelog-signing-network-params.xml b/network-management/src/main/resources/migration/network-manager.changelog-signing-network-params.xml deleted file mode 100644 index 27c685ea96..0000000000 --- a/network-management/src/main/resources/migration/network-manager.changelog-signing-network-params.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - -