mirror of
https://github.com/corda/corda.git
synced 2024-12-21 13:57:54 +00:00
CORDA-4083: Fix Postresql migration, synch migration scripts from ENT (#6817)
This commit is contained in:
parent
a8ae7fdd6a
commit
503644ca29
@ -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*/
|
||||
|
@ -4,11 +4,45 @@
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
|
||||
|
||||
<changeSet author="R3.Corda" id="node_transaction_id_size">
|
||||
<dropPrimaryKey tableName="node_transactions" constraintName="node_transactions_pkey"/>
|
||||
<dropPrimaryKey tableName="node_scheduled_states" constraintName="node_scheduled_states_pkey"/>
|
||||
|
||||
<dropNotNullConstraint tableName="node_transactions" columnName="tx_id" columnDataType="NVARCHAR(64)" />
|
||||
<dropNotNullConstraint tableName="node_scheduled_states" columnName="transaction_id" columnDataType="NVARCHAR(64)" />
|
||||
|
||||
<modifyDataType tableName="node_transactions"
|
||||
columnName="tx_id"
|
||||
newDataType="NVARCHAR(144)"/>
|
||||
<modifyDataType tableName="node_scheduled_states"
|
||||
columnName="transaction_id"
|
||||
newDataType="NVARCHAR(144)"/>
|
||||
|
||||
<addNotNullConstraint tableName="node_transactions" columnName="tx_id" columnDataType="NVARCHAR(144)"/>
|
||||
<addNotNullConstraint tableName="node_scheduled_states" columnName="transaction_id" columnDataType="NVARCHAR(144)"/>
|
||||
|
||||
<addPrimaryKey columnNames="tx_id" constraintName="node_transactions_pkey" tableName="node_transactions"/>
|
||||
<addPrimaryKey columnNames="output_index, transaction_id" constraintName="node_scheduled_states_pkey"
|
||||
tableName="node_scheduled_states"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet author="R3.Corda" id="node_transaction_id_size_non-clustered_pk" onValidationFail="MARK_RAN">
|
||||
<dropPrimaryKey tableName="node_transactions" constraintName="node_transactions_pkey"/>
|
||||
<addPrimaryKey tableName="node_transactions" columnNames="tx_id" constraintName="node_transactions_pkey"
|
||||
clustered="false"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet author="R3.Corda" id="node_contract_upgrades_state_ref_size">
|
||||
<dropPrimaryKey tableName="node_contract_upgrades" constraintName="node_contract_upgrades_pkey"/>
|
||||
|
||||
<dropNotNullConstraint tableName="node_contract_upgrades" columnName="state_ref" columnDataType="NVARCHAR(96)" />
|
||||
|
||||
<modifyDataType tableName="node_contract_upgrades"
|
||||
columnName="state_ref"
|
||||
newDataType="NVARCHAR(176)"/>
|
||||
|
||||
<addNotNullConstraint tableName="node_contract_upgrades" columnName="state_ref" columnDataType="NVARCHAR(176)"/>
|
||||
|
||||
<addPrimaryKey columnNames="state_ref" constraintName="node_contract_upgrades_pkey"
|
||||
tableName="node_contract_upgrades"/>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
@ -4,6 +4,14 @@
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
|
||||
|
||||
<changeSet author="R3.Corda" id="node_notary_transaction_id_size">
|
||||
<dropPrimaryKey tableName="node_notary_committed_txs" constraintName="node_notary_transactions_pkey"/>
|
||||
<dropPrimaryKey tableName="node_notary_committed_states" constraintName="node_notary_states_pkey"/>
|
||||
|
||||
<dropNotNullConstraint tableName="node_notary_committed_txs" columnName="transaction_id" columnDataType="NVARCHAR(64)" />
|
||||
<dropNotNullConstraint tableName="node_notary_committed_states" columnName="transaction_id" columnDataType="NVARCHAR(64)" />
|
||||
<dropNotNullConstraint tableName="node_notary_committed_states" columnName="consuming_transaction_id" columnDataType="NVARCHAR(64)" />
|
||||
<dropNotNullConstraint tableName="node_notary_request_log" columnName="consuming_transaction_id" columnDataType="NVARCHAR(64)" />
|
||||
|
||||
<modifyDataType tableName="node_notary_committed_txs"
|
||||
columnName="transaction_id"
|
||||
newDataType="NVARCHAR(144)"/>
|
||||
@ -16,5 +24,21 @@
|
||||
<modifyDataType tableName="node_notary_request_log"
|
||||
columnName="consuming_transaction_id"
|
||||
newDataType="NVARCHAR(144)"/>
|
||||
|
||||
<addNotNullConstraint tableName="node_notary_committed_txs" columnName="transaction_id" columnDataType="NVARCHAR(144)"/>
|
||||
<addNotNullConstraint tableName="node_notary_committed_states" columnName="transaction_id" columnDataType="NVARCHAR(144)"/>
|
||||
<addNotNullConstraint tableName="node_notary_committed_states" columnName="consuming_transaction_id" columnDataType="NVARCHAR(144)"/>
|
||||
<addNotNullConstraint tableName="node_notary_request_log" columnName="consuming_transaction_id" columnDataType="NVARCHAR(144)"/>
|
||||
|
||||
<addPrimaryKey columnNames="transaction_id" constraintName="node_notary_transactions_pkey" tableName="node_notary_committed_txs"/>
|
||||
<addPrimaryKey columnNames="output_index, transaction_id" constraintName="node_notary_states_pkey"
|
||||
tableName="node_notary_committed_states"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="node_notary_transaction_id_size-non-clustered_pk" author="R3.Corda" onValidationFail="MARK_RAN">
|
||||
<dropPrimaryKey tableName="node_notary_committed_states" constraintName="node_notary_states_pkey"/>
|
||||
<addPrimaryKey tableName="node_notary_committed_states" columnNames="output_index, transaction_id"
|
||||
constraintName="node_notary_states_pkey" clustered="false"/>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
@ -4,6 +4,14 @@
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
|
||||
|
||||
<changeSet author="R3.Corda" id="node_bft_transaction_id_size">
|
||||
<dropPrimaryKey tableName="node_bft_committed_states" constraintName="node_bft_states_pkey"/>
|
||||
<dropPrimaryKey tableName="node_bft_committed_txs" constraintName="node_bft_transactions_pkey"/>
|
||||
|
||||
<dropNotNullConstraint tableName="node_bft_committed_states" columnName="transaction_id" columnDataType="NVARCHAR(64)" />
|
||||
<dropNotNullConstraint tableName="node_bft_committed_states" columnName="consuming_transaction_id" columnDataType="NVARCHAR(64)" />
|
||||
<dropNotNullConstraint tableName="node_notary_request_log" columnName="consuming_transaction_id" columnDataType="NVARCHAR(64)" />
|
||||
<dropNotNullConstraint tableName="node_bft_committed_txs" columnName="transaction_id" columnDataType="NVARCHAR(64)" />
|
||||
|
||||
<modifyDataType tableName="node_bft_committed_states"
|
||||
columnName="transaction_id"
|
||||
newDataType="NVARCHAR(144)"/>
|
||||
@ -13,5 +21,23 @@
|
||||
<modifyDataType tableName="node_notary_request_log"
|
||||
columnName="consuming_transaction_id"
|
||||
newDataType="NVARCHAR(144)"/>
|
||||
<modifyDataType tableName="node_bft_committed_txs"
|
||||
columnName="transaction_id"
|
||||
newDataType="NVARCHAR(144)"/>
|
||||
|
||||
<addNotNullConstraint tableName="node_bft_committed_states" columnName="transaction_id" columnDataType="NVARCHAR(144)"/>
|
||||
<addNotNullConstraint tableName="node_bft_committed_states" columnName="consuming_transaction_id" columnDataType="NVARCHAR(144)"/>
|
||||
<addNotNullConstraint tableName="node_notary_request_log" columnName="consuming_transaction_id" columnDataType="NVARCHAR(144)"/>
|
||||
<addNotNullConstraint tableName="node_bft_committed_txs" columnName="transaction_id" columnDataType="NVARCHAR(144)"/>
|
||||
|
||||
<addPrimaryKey columnNames="output_index, transaction_id" constraintName="node_bft_states_pkey"
|
||||
tableName="node_bft_committed_states"/>
|
||||
<addPrimaryKey columnNames="transaction_id" constraintName="node_bft_transactions_pkey" tableName="node_bft_committed_txs"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="node_bft_transaction_id_size-non-clustered_pk" author="R3.Corda" onValidationFail="MARK_RAN">
|
||||
<dropPrimaryKey tableName="node_bft_committed_states" constraintName="node_bft_states_pkey"/>
|
||||
<addPrimaryKey tableName="node_bft_committed_states" columnNames="output_index, transaction_id"
|
||||
constraintName="node_bft_states_pkey" clustered="false"/>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
@ -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">
|
||||
<changeSet author="R3.Corda" id="nullability">
|
||||
<addNotNullConstraint tableName="node_raft_committed_states" columnName="state_index" columnDataType="BIGINT"/>
|
||||
<addNotNullConstraint tableName="node_raft_committed_states" columnName="state_value" columnDataType="BLOB"/>
|
||||
</changeSet>
|
||||
<changeSet author="R3.Corda" id="node_raft_transaction_id_size">
|
||||
<dropPrimaryKey tableName="node_raft_committed_txs" constraintName="node_raft_transactions_pkey"/>
|
||||
|
||||
<dropNotNullConstraint tableName="node_raft_committed_txs" columnName="transaction_id" columnDataType="NVARCHAR(64)" />
|
||||
<dropNotNullConstraint tableName="node_notary_request_log" columnName="consuming_transaction_id" columnDataType="NVARCHAR(64)" />
|
||||
|
||||
<modifyDataType tableName="node_raft_committed_txs"
|
||||
columnName="transaction_id"
|
||||
newDataType="NVARCHAR(144)"/>
|
||||
<modifyDataType tableName="node_notary_request_log"
|
||||
columnName="consuming_transaction_id"
|
||||
newDataType="NVARCHAR(144)"/>
|
||||
|
||||
<addNotNullConstraint tableName="node_raft_committed_txs" columnName="transaction_id" columnDataType="NVARCHAR(144)"/>
|
||||
<addNotNullConstraint tableName="node_notary_request_log" columnName="consuming_transaction_id" columnDataType="NVARCHAR(144)"/>
|
||||
|
||||
<addPrimaryKey columnNames="transaction_id" constraintName="node_raft_transactions_pkey" tableName="node_raft_committed_txs"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet author="R3.Corda" id="node_raft_committed_states_id_size">
|
||||
<dropPrimaryKey tableName="node_raft_committed_states" constraintName="node_raft_state_pkey"/>
|
||||
<dropNotNullConstraint tableName="node_raft_committed_states" columnName="id" columnDataType="NVARCHAR(128)"/>
|
||||
|
||||
<modifyDataType tableName="node_raft_committed_states"
|
||||
columnName="id"
|
||||
newDataType="NVARCHAR(208)"/>
|
||||
|
||||
<addNotNullConstraint tableName="node_raft_committed_states" columnName="id" columnDataType="NVARCHAR(208)"/>
|
||||
<addPrimaryKey columnNames="id" constraintName="node_raft_state_pkey" tableName="node_raft_committed_states"/>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
@ -12,5 +12,5 @@
|
||||
<include file="migration/vault-schema.changelog-v7.xml"/>
|
||||
<include file="migration/vault-schema.changelog-v8.xml"/>
|
||||
<include file="migration/vault-schema.changelog-v11.xml"/>
|
||||
<include file="migration/vault-schema.changelog-v12.xml"/>
|
||||
<include file="migration/vault-schema.changelog-v13.xml"/>
|
||||
</databaseChangeLog>
|
||||
|
@ -1,29 +0,0 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
|
||||
|
||||
<changeSet author="R3.Corda" id="vault_transaction_id_size">
|
||||
<modifyDataType tableName="vault_fungible_states"
|
||||
columnName="transaction_id"
|
||||
newDataType="NVARCHAR(144)"/>
|
||||
<modifyDataType tableName="vault_fungible_states_parts"
|
||||
columnName="transaction_id"
|
||||
newDataType="NVARCHAR(144)"/>
|
||||
<modifyDataType tableName="vault_linear_states"
|
||||
columnName="transaction_id"
|
||||
newDataType="NVARCHAR(144)"/>
|
||||
<modifyDataType tableName="vault_linear_states_parts"
|
||||
columnName="transaction_id"
|
||||
newDataType="NVARCHAR(144)"/>
|
||||
<modifyDataType tableName="vault_states"
|
||||
columnName="transaction_id"
|
||||
newDataType="NVARCHAR(144)"/>
|
||||
<modifyDataType tableName="vault_transaction_notes"
|
||||
columnName="transaction_id"
|
||||
newDataType="NVARCHAR(144)"/>
|
||||
<modifyDataType tableName="state_party"
|
||||
columnName="transaction_id"
|
||||
newDataType="NVARCHAR(144)"/>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
103
node/src/main/resources/migration/vault-schema.changelog-v13.xml
Normal file
103
node/src/main/resources/migration/vault-schema.changelog-v13.xml
Normal file
@ -0,0 +1,103 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
|
||||
|
||||
<changeSet author="R3.Corda" id="vault_transaction_id_size">
|
||||
<!-- dropView to avoid org.postgresql.util.PSQLException: cannot alter type of a column used by a view or rule -->
|
||||
<dropView viewName="v_pkey_hash_ex_id_map"/>
|
||||
|
||||
<dropForeignKeyConstraint baseTableName="vault_fungible_states_parts"
|
||||
constraintName="FK__fung_st_parts__fung_st"/>
|
||||
<dropForeignKeyConstraint baseTableName="vault_linear_states_parts"
|
||||
constraintName="FK__lin_stat_parts__lin_stat"/>
|
||||
<dropPrimaryKey tableName="vault_fungible_states" constraintName="vault_fungible_states_pkey"/>
|
||||
<dropPrimaryKey tableName="vault_linear_states" constraintName="vault_linear_states_pkey"/>
|
||||
<dropPrimaryKey tableName="vault_states" constraintName="vault_states_pkey"/>
|
||||
<dropIndex indexName="transaction_id_index" tableName="vault_transaction_notes"/>
|
||||
|
||||
<dropNotNullConstraint tableName="vault_fungible_states" columnName="transaction_id" columnDataType="NVARCHAR(64)" />
|
||||
<dropNotNullConstraint tableName="vault_fungible_states_parts" columnName="transaction_id" columnDataType="NVARCHAR(64)" />
|
||||
<dropNotNullConstraint tableName="vault_linear_states" columnName="transaction_id" columnDataType="NVARCHAR(64)" />
|
||||
<dropNotNullConstraint tableName="vault_linear_states_parts" columnName="transaction_id" columnDataType="NVARCHAR(64)" />
|
||||
<dropNotNullConstraint tableName="vault_states" columnName="transaction_id" columnDataType="NVARCHAR(64)" />
|
||||
|
||||
<modifyDataType tableName="vault_fungible_states"
|
||||
columnName="transaction_id"
|
||||
newDataType="NVARCHAR(144)"/>
|
||||
<modifyDataType tableName="vault_fungible_states_parts"
|
||||
columnName="transaction_id"
|
||||
newDataType="NVARCHAR(144)"/>
|
||||
<modifyDataType tableName="vault_linear_states"
|
||||
columnName="transaction_id"
|
||||
newDataType="NVARCHAR(144)"/>
|
||||
<modifyDataType tableName="vault_linear_states_parts"
|
||||
columnName="transaction_id"
|
||||
newDataType="NVARCHAR(144)"/>
|
||||
<modifyDataType tableName="vault_states"
|
||||
columnName="transaction_id"
|
||||
newDataType="NVARCHAR(144)"/>
|
||||
<modifyDataType tableName="vault_transaction_notes"
|
||||
columnName="transaction_id"
|
||||
newDataType="NVARCHAR(144)"/>
|
||||
<modifyDataType tableName="state_party"
|
||||
columnName="transaction_id"
|
||||
newDataType="NVARCHAR(144)"/>
|
||||
|
||||
<addNotNullConstraint tableName="vault_fungible_states" columnName="transaction_id" columnDataType="NVARCHAR(144)"/>
|
||||
<addNotNullConstraint tableName="vault_fungible_states_parts" columnName="transaction_id" columnDataType="NVARCHAR(144)"/>
|
||||
<addNotNullConstraint tableName="vault_linear_states" columnName="transaction_id" columnDataType="NVARCHAR(144)"/>
|
||||
<addNotNullConstraint tableName="vault_linear_states_parts" columnName="transaction_id" columnDataType="NVARCHAR(144)"/>
|
||||
<addNotNullConstraint tableName="vault_states" columnName="transaction_id" columnDataType="NVARCHAR(144)"/>
|
||||
|
||||
<addPrimaryKey tableName="vault_fungible_states" columnNames="transaction_id, output_index"
|
||||
constraintName="vault_fungible_states_pkey"/>
|
||||
<addPrimaryKey tableName="vault_linear_states" columnNames="transaction_id, output_index"
|
||||
constraintName="vault_linear_states_pkey"/>
|
||||
<addPrimaryKey tableName="vault_states" columnNames="transaction_id, output_index"
|
||||
constraintName="vault_states_pkey"/>
|
||||
<createIndex indexName="transaction_id_index" tableName="vault_transaction_notes">
|
||||
<column name="transaction_id"/>
|
||||
</createIndex>
|
||||
</changeSet>
|
||||
|
||||
<changeSet author="R3.Corda" id="vault_transaction_id_size_non-clustered_pk-1" onValidationFail="MARK_RAN">
|
||||
<dropPrimaryKey tableName="vault_fungible_states" constraintName="vault_fungible_states_pkey"/>
|
||||
<addPrimaryKey tableName="vault_fungible_states" columnNames="transaction_id, output_index"
|
||||
constraintName="vault_fungible_states_pkey" clustered="false"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet author="R3.Corda" id="vault_transaction_id_size_non-clustered_pk-2" onValidationFail="MARK_RAN">
|
||||
<dropPrimaryKey tableName="vault_linear_states" constraintName="vault_linear_states_pkey"/>
|
||||
<addPrimaryKey tableName="vault_linear_states" columnNames="transaction_id, output_index"
|
||||
constraintName="vault_linear_states_pkey" clustered="false"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet author="R3.Corda" id="vault_transaction_id_size_non-clustered_pk-3" onValidationFail="MARK_RAN">
|
||||
<dropPrimaryKey tableName="vault_states" constraintName="vault_states_pkey"/>
|
||||
<addPrimaryKey tableName="vault_states" columnNames="transaction_id, output_index"
|
||||
constraintName="vault_states_pkey" clustered="false"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet author="R3.Corda" id="vault_transaction_id_size_2">
|
||||
<addForeignKeyConstraint baseColumnNames="transaction_id,output_index"
|
||||
baseTableName="vault_fungible_states_parts"
|
||||
constraintName="FK__fung_st_parts__fung_st"
|
||||
referencedColumnNames="transaction_id,output_index"
|
||||
referencedTableName="vault_fungible_states"/>
|
||||
<addForeignKeyConstraint baseColumnNames="transaction_id,output_index" baseTableName="vault_linear_states_parts"
|
||||
constraintName="FK__lin_stat_parts__lin_stat"
|
||||
referencedColumnNames="transaction_id,output_index"
|
||||
referencedTableName="vault_linear_states"/>
|
||||
<createView viewName="v_pkey_hash_ex_id_map">
|
||||
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
|
||||
</createView>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user