From 503644ca295c85847430b4e489716dd34da047a8 Mon Sep 17 00:00:00 2001 From: Denis Rekalov Date: Tue, 24 Nov 2020 20:03:36 +0000 Subject: [PATCH] CORDA-4083: Fix Postresql migration, synch migration scripts from ENT (#6817) --- .../upgrade/ContractUpgradeServiceImpl.kt | 2 +- .../migration/node-core.changelog-v21.xml | 34 ++++++ .../migration/node-notary.changelog-v4.xml | 24 ++++ .../notary-bft-smart.changelog-v2.xml | 26 +++++ .../migration/notary-raft.changelog-v2.xml | 26 ++++- .../vault-schema.changelog-master.xml | 2 +- .../migration/vault-schema.changelog-v12.xml | 29 ----- .../migration/vault-schema.changelog-v13.xml | 103 ++++++++++++++++++ .../node/utilities/PersistentMapTests.kt | 16 +++ 9 files changed, 227 insertions(+), 35 deletions(-) delete mode 100644 node/src/main/resources/migration/vault-schema.changelog-v12.xml create mode 100644 node/src/main/resources/migration/vault-schema.changelog-v13.xml diff --git a/node/src/main/kotlin/net/corda/node/services/upgrade/ContractUpgradeServiceImpl.kt b/node/src/main/kotlin/net/corda/node/services/upgrade/ContractUpgradeServiceImpl.kt index b28ef53b8a..351864a741 100644 --- a/node/src/main/kotlin/net/corda/node/services/upgrade/ContractUpgradeServiceImpl.kt +++ b/node/src/main/kotlin/net/corda/node/services/upgrade/ContractUpgradeServiceImpl.kt @@ -19,7 +19,7 @@ class ContractUpgradeServiceImpl(cacheFactory: NamedCacheFactory) : ContractUpgr @Table(name = "${NODE_DATABASE_PREFIX}contract_upgrades") class DBContractUpgrade( @Id - @Column(name = "state_ref", length = 96, nullable = false) + @Column(name = "state_ref", length = 176, nullable = false) var stateRef: String = "", /** refers to the UpgradedContract class name*/ diff --git a/node/src/main/resources/migration/node-core.changelog-v21.xml b/node/src/main/resources/migration/node-core.changelog-v21.xml index 7773bc7f91..ee04567f1a 100644 --- a/node/src/main/resources/migration/node-core.changelog-v21.xml +++ b/node/src/main/resources/migration/node-core.changelog-v21.xml @@ -4,11 +4,45 @@ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/node/src/main/resources/migration/node-notary.changelog-v4.xml b/node/src/main/resources/migration/node-notary.changelog-v4.xml index c2a15576ec..7cd5a8117d 100644 --- a/node/src/main/resources/migration/node-notary.changelog-v4.xml +++ b/node/src/main/resources/migration/node-notary.changelog-v4.xml @@ -4,6 +4,14 @@ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd"> + + + + + + + + @@ -16,5 +24,21 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/node/src/main/resources/migration/notary-bft-smart.changelog-v2.xml b/node/src/main/resources/migration/notary-bft-smart.changelog-v2.xml index a63bc827ca..bc62adb0fe 100644 --- a/node/src/main/resources/migration/notary-bft-smart.changelog-v2.xml +++ b/node/src/main/resources/migration/notary-bft-smart.changelog-v2.xml @@ -4,6 +4,14 @@ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd"> + + + + + + + + @@ -13,5 +21,23 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/node/src/main/resources/migration/notary-raft.changelog-v2.xml b/node/src/main/resources/migration/notary-raft.changelog-v2.xml index ddb0db5742..10b7d76452 100644 --- a/node/src/main/resources/migration/notary-raft.changelog-v2.xml +++ b/node/src/main/resources/migration/notary-raft.changelog-v2.xml @@ -4,16 +4,34 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd" logicalFilePath="migration/node-services.changelog-init.xml"> - - - - + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/node/src/main/resources/migration/vault-schema.changelog-master.xml b/node/src/main/resources/migration/vault-schema.changelog-master.xml index d3616c5c0c..44684647fa 100644 --- a/node/src/main/resources/migration/vault-schema.changelog-master.xml +++ b/node/src/main/resources/migration/vault-schema.changelog-master.xml @@ -12,5 +12,5 @@ - + diff --git a/node/src/main/resources/migration/vault-schema.changelog-v12.xml b/node/src/main/resources/migration/vault-schema.changelog-v12.xml deleted file mode 100644 index 8dc736a149..0000000000 --- a/node/src/main/resources/migration/vault-schema.changelog-v12.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/node/src/main/resources/migration/vault-schema.changelog-v13.xml b/node/src/main/resources/migration/vault-schema.changelog-v13.xml new file mode 100644 index 0000000000..beb66dba82 --- /dev/null +++ b/node/src/main/resources/migration/vault-schema.changelog-v13.xml @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + state_party.public_key_hash, + state_party.transaction_id, + state_party.output_index, + pk_hash_to_ext_id_map.external_id + from state_party + join pk_hash_to_ext_id_map + on state_party.public_key_hash = pk_hash_to_ext_id_map.public_key_hash + + + \ No newline at end of file diff --git a/node/src/test/kotlin/net/corda/node/utilities/PersistentMapTests.kt b/node/src/test/kotlin/net/corda/node/utilities/PersistentMapTests.kt index f2d08608cf..3f15c6d298 100644 --- a/node/src/test/kotlin/net/corda/node/utilities/PersistentMapTests.kt +++ b/node/src/test/kotlin/net/corda/node/utilities/PersistentMapTests.kt @@ -47,6 +47,22 @@ class PersistentMapTests { } } + @Test(timeout=300_000) + fun `make sure persistence works with SHA-512`() { + val testHash = SecureHash.random(SecureHash.SHA2_512).toString() + + database.transaction { + val map = createTestMap() + map[testHash] = "test" + assertEquals(map[testHash], "test") + } + + database.transaction { + val reloadedMap = createTestMap() + assertEquals("test", reloadedMap[testHash]) + } + } + @Test(timeout=300_000) fun `make sure persistence works using assignment operator`() { val testHash = SecureHash.randomSHA256().toString()