ENT-1943 non clustered primary keys (#880)

* ENT-1943 Add liquibase change sets to remove clustered indices from primary  keys

* ENT-1943 Add liquibase change sets to remove clustered indices from primary  keys

* Don't apply non-clustered PK change when using H2

* Move primary key changesets to separate file for core migration files
Use `onValidationFail` rather than precondition to exclude these changes from H2

* Remove/readd foreign key constraint to make SQL server less unhappy

* Fix linear states schema migration

* Fix notary states changelog issues

* Remove v3-GA from master changelog
This commit is contained in:
Christian Sailer 2018-06-12 15:40:25 +01:00 committed by GitHub
parent e42403d7a3
commit b09a57d768
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 154 additions and 0 deletions

View File

@ -38,4 +38,10 @@
<column name="pennies"/>
</createIndex>
</changeSet>
<changeSet id="non-clustered_pk-cash" author="R3.Corda" onValidationFail="MARK_RAN">
<dropPrimaryKey tableName="contract_cash_states" constraintName="contract_cash_states_pkey"/>
<addPrimaryKey tableName="contract_cash_states" columnNames="output_index, transaction_id"
constraintName="contract_cash_states_pkey" clustered="false"/>
</changeSet>
</databaseChangeLog>

View File

@ -46,4 +46,10 @@
<column name="maturity_instant"/>
</createIndex>
</changeSet>
<changeSet id="non-clustered_pk-commercial-paper" author="R3.Corda" onValidationFail="MARK_RAN">
<dropPrimaryKey tableName="cp_states" constraintName="cp_states_pkey"/>
<addPrimaryKey tableName="cp_states" columnNames="output_index, transaction_id" constraintName="cp_states_pkey"
clustered="false"/>
</changeSet>
</databaseChangeLog>

View File

@ -17,5 +17,6 @@
<include file="migration/node-core.changelog-init.xml"/>
<include file="migration/node-core.changelog-v3.xml"/>
<include file="migration/node-core.changelog-v4.xml"/>
<include file="migration/node-core.changelog-pkey.xml"/>
</databaseChangeLog>

View File

@ -0,0 +1,51 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<!--
~ R3 Proprietary and Confidential
~
~ Copyright (c) 2018 R3 Limited. All rights reserved.
~
~ The intellectual and technical concepts contained herein are proprietary to R3 and its suppliers and are protected by trade secret law.
~
~ Distribution of this file or any portion thereof via any medium without the express permission of R3 is strictly prohibited.
-->
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
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">
<changeSet id="non-clustered_pk-1" author="R3.Corda" onValidationFail="MARK_RAN">
<dropPrimaryKey tableName="node_checkpoints" constraintName="node_checkpoints_pkey"/>
<addPrimaryKey tableName="node_checkpoints" columnNames="checkpoint_id" constraintName="node_checkpoints_pkey"
clustered="false"/>
</changeSet>
<changeSet id="non-clustered_pk-2" author="R3.Corda" onValidationFail="MARK_RAN">
<dropPrimaryKey tableName="node_identities" constraintName="node_identities_pkey"/>
<addPrimaryKey tableName="node_identities" columnNames="pk_hash" constraintName="node_identities_pkey"
clustered="false"/>
</changeSet>
<changeSet id="non-clustered_pk-3" author="R3.Corda" onValidationFail="MARK_RAN">
<dropPrimaryKey tableName="node_message_ids" constraintName="node_message_ids_pkey"/>
<addPrimaryKey tableName="node_message_ids" columnNames="message_id" constraintName="node_message_ids_pkey"
clustered="false"/>
</changeSet>
<changeSet id="non-clustered_pk-4" author="R3.Corda" onValidationFail="MARK_RAN">
<dropPrimaryKey tableName="node_named_identities" constraintName="node_named_identities_pkey"/>
<addPrimaryKey tableName="node_named_identities" columnNames="name" constraintName="node_named_identities_pkey"
clustered="false"/>
</changeSet>
<changeSet id="non-clustered_pk-5" author="R3.Corda" onValidationFail="MARK_RAN">
<dropPrimaryKey tableName="node_our_key_pairs" constraintName="node_our_key_pairs_pkey"/>
<addPrimaryKey tableName="node_our_key_pairs" columnNames="public_key_hash"
constraintName="node_our_key_pairs_pkey" clustered="false"/>
</changeSet>
<changeSet id="non-clustered_pk-6" author="R3.Corda" onValidationFail="MARK_RAN">
<dropPrimaryKey tableName="node_transaction_mappings" constraintName="node_transaction_mappings_pkey"/>
<addPrimaryKey tableName="node_transaction_mappings" columnNames="tx_id"
constraintName="node_transaction_mappings_pkey" clustered="false"/>
</changeSet>
<changeSet id="non-clustered_pk-7" author="R3.Corda" 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>
</databaseChangeLog>

View File

@ -15,6 +15,8 @@
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">
<include file="migration/node-notary.changelog-init.xml"/>
<include file="migration/node-notary.changelog-v1.xml"/>
<include file="migration/node-notary.changelog-pkey.xml"/>
</databaseChangeLog>

View File

@ -0,0 +1,31 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<!--
~ R3 Proprietary and Confidential
~
~ Copyright (c) 2018 R3 Limited. All rights reserved.
~
~ The intellectual and technical concepts contained herein are proprietary to R3 and its suppliers and are protected by trade secret law.
~
~ Distribution of this file or any portion thereof via any medium without the express permission of R3 is strictly prohibited.
-->
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
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">
<changeSet id="non-clustered_pk-notary_state" 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>
<changeSet id="non-clustered_pk-bft_stae" 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>
<changeSet id="non-clustered_pk-raft_state" author="R3.Corda" onValidationFail="MARK_RAN">
<dropPrimaryKey tableName="node_raft_committed_states" constraintName="node_raft_state_pkey"/>
<addPrimaryKey tableName="node_raft_committed_states" columnNames="output_index, transaction_id"
constraintName="node_raft_state_pkey" clustered="false"/>
</changeSet>
</databaseChangeLog>

View File

@ -17,5 +17,6 @@
<include file="migration/vault-schema.changelog-init.xml"/>
<include file="migration/vault-schema.changelog-v3.xml"/>
<include file="migration/vault-schema.changelog-v4.xml"/>
<include file="migration/vault-schema.changelog-pkey.xml"/>
</databaseChangeLog>

View File

@ -0,0 +1,45 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<!--
~ R3 Proprietary and Confidential
~
~ Copyright (c) 2018 R3 Limited. All rights reserved.
~
~ The intellectual and technical concepts contained herein are proprietary to R3 and its suppliers and are protected by trade secret law.
~
~ Distribution of this file or any portion thereof via any medium without the express permission of R3 is strictly prohibited.
-->
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
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">
<changeSet id="non-clustered_pk-11" author="R3.Corda" onValidationFail="MARK_RAN">
<dropForeignKeyConstraint baseTableName="vault_fungible_states_parts" constraintName="FK__fung_st_parts__fung_st"/>
<dropPrimaryKey tableName="vault_fungible_states" constraintName="vault_fungible_states_pkey"/>
<addPrimaryKey tableName="vault_fungible_states" columnNames="output_index, transaction_id"
constraintName="vault_fungible_states_pkey" clustered="false"/>
<addForeignKeyConstraint baseColumnNames="output_index,transaction_id"
baseTableName="vault_fungible_states_parts"
constraintName="FK__fung_st_parts__fung_st"
referencedColumnNames="output_index,transaction_id"
referencedTableName="vault_fungible_states"/>
</changeSet>
<changeSet id="non-clustered_pk-12" author="R3.Corda" onValidationFail="MARK_RAN">
<dropForeignKeyConstraint baseTableName="vault_linear_states_parts" constraintName="FK__lin_stat_parts__lin_stat"/>
<dropPrimaryKey tableName="vault_linear_states" constraintName="vault_linear_states_pkey"/>
<addPrimaryKey tableName="vault_linear_states" columnNames="output_index, transaction_id"
constraintName="vault_linear_states_pkey" clustered="false"/>
<addForeignKeyConstraint baseColumnNames="output_index,transaction_id" baseTableName="vault_linear_states_parts"
constraintName="FK__lin_stat_parts__lin_stat"
referencedColumnNames="output_index,transaction_id"
referencedTableName="vault_linear_states"/>
</changeSet>
<changeSet id="non-clustered_pk-13" author="R3.Corda" onValidationFail="MARK_RAN">
<dropPrimaryKey tableName="vault_states" constraintName="vault_states_pkey"/>
<addPrimaryKey tableName="vault_states" columnNames="output_index, transaction_id"
constraintName="vault_states_pkey" clustered="false"/>
</changeSet>
</databaseChangeLog>

View File

@ -38,4 +38,9 @@
<column name="pennies"/>
</createIndex>
</changeSet>
<changeSet id="non-clustered_pk-cash-pt" author="R3.Corda" onValidationFail="MARK_RAN">
<dropPrimaryKey tableName="contract_pt_cash_states" constraintName="contract_pt_cash_states_pkey"/>
<addPrimaryKey tableName="contract_pt_cash_states" columnNames="output_index, transaction_id"
constraintName="contract_pt_cash_states_pkey" clustered="false"/>
</changeSet>
</databaseChangeLog>

View File

@ -46,4 +46,10 @@
<column name="maturity_instant"/>
</createIndex>
</changeSet>
<changeSet id="non-clustered_pk_pt-commercial-paper" author="R3.Corda" onValidationFail="MARK_RAN">
<dropPrimaryKey tableName="cp_pt_states" constraintName="cp_pt_states_pkey"/>
<addPrimaryKey tableName="cp_pt_states" columnNames="output_index, transaction_id"
constraintName="cp_pt_states_pkey" clustered="false"/>
</changeSet>
</databaseChangeLog>