[CORDA-1297] Column nullability in migrations (#916)

* Migrations to proper nullability

* Removed node-core.changelog-v3-GA.xml file as indicated by PR comments, This change was already provided by nullability upgrade commits
This commit is contained in:
Maksymilian Pawlak 2018-06-05 18:13:49 +01:00 committed by GitHub
parent b0f5b81d26
commit f4621d9a74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 268 additions and 40 deletions

View File

@ -12,5 +12,6 @@
<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" >
<include file="migration/cash.changelog-init.xml"/>
<include file="migration/cash.changelog-v1.xml"/>
</databaseChangeLog>

View File

@ -5,8 +5,11 @@
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="rename_contract_attachment">
<renameTable newTableName="node_attachments_contracts"
oldTableName="node_attchments_contracts"/>
<changeSet id="1525793504" author="R3.Corda">
<addNotNullConstraint tableName="contract_cash_states" columnName="ccy_code" columnDataType="NVARCHAR(3)"/>
<addNotNullConstraint tableName="contract_cash_states" columnName="issuer_key_hash"
columnDataType="NVARCHAR(130)"/>
<addNotNullConstraint tableName="contract_cash_states" columnName="issuer_ref" columnDataType="varbinary(512)"/>
<addNotNullConstraint tableName="contract_cash_states" columnName="pennies" columnDataType="BIGINT"/>
</changeSet>
</databaseChangeLog>
</databaseChangeLog>

View File

@ -12,5 +12,6 @@
<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">
<include file="migration/commercial-paper.changelog-init.xml"/>
<include file="migration/commercial-paper.changelog-v1.xml"/>
</databaseChangeLog>

View File

@ -0,0 +1,24 @@
<?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 author="R3.Corda" id="1525962920">
<addNotNullConstraint tableName="cp_states" columnName="ccy_code" columnDataType="NVARCHAR(3)"/>
<addNotNullConstraint tableName="cp_states" columnName="face_value" columnDataType="BIGINT"/>
<addNotNullConstraint tableName="cp_states" columnName="face_value_issuer_key_hash" columnDataType="NVARCHAR(130)"/>
<addNotNullConstraint tableName="cp_states" columnName="face_value_issuer_ref" columnDataType="varbinary(512)"/>
<addNotNullConstraint tableName="cp_states" columnName="issuance_key_hash" columnDataType="NVARCHAR(130)"/>
<addNotNullConstraint tableName="cp_states" columnName="issuance_ref" columnDataType="varbinary(255)"/>
<addNotNullConstraint tableName="cp_states" columnName="maturity_instant" columnDataType="timestamp"/>
<addNotNullConstraint tableName="cp_states" columnName="owner_key_hash" columnDataType="NVARCHAR(130)"/>
</changeSet>
</databaseChangeLog>

View File

@ -21,11 +21,21 @@
<column name="transaction_id" type="NVARCHAR(64)">
<constraints nullable="false"/>
</column>
<column name="ccy_code" type="NVARCHAR(3)"/>
<column name="issuer_key_hash" type="NVARCHAR(130)"/>
<column name="issuer_ref" type="varbinary(512)"/>
<column name="owner_key_hash" type="NVARCHAR(130)"/>
<column name="pennies" type="BIGINT"/>
<column name="ccy_code" type="NVARCHAR(3)">
<constraints nullable="false"/>
</column>
<column name="issuer_key_hash" type="NVARCHAR(130)">
<constraints nullable="false"/>
</column>
<column name="issuer_ref" type="varbinary(512)">
<constraints nullable="false"/>
</column>
<column name="owner_key_hash" type="NVARCHAR(130)">
<constraints nullable="false"/>
</column>
<column name="pennies" type="BIGINT">
<constraints nullable="false"/>
</column>
</createTable>
</changeSet>
<changeSet author="R3.Corda" id="1511451595465-28">

View File

@ -23,10 +23,16 @@
<constraints nullable="false"/>
</column>
<column name="issuer_name" type="NVARCHAR(255)"/>
<column name="issuer_ref" type="VARBINARY(512)"/>
<column name="issuer_ref" type="VARBINARY(512)">
<constraints nullable="false"/>
</column>
<column name="owner_name" type="NVARCHAR(255)"/>
<column name="quantity" type="BIGINT"/>
<column name="ccy_code" type="NVARCHAR(3)"/>
<column name="quantity" type="BIGINT">
<constraints nullable="false"/>
</column>
<column name="ccy_code" type="NVARCHAR(3)">
<constraints nullable="false"/>
</column>
</createTable>
<addPrimaryKey columnNames="output_index, transaction_id" constraintName="CONSTRAINT_D"

View File

@ -22,11 +22,21 @@
<column name="transaction_id" type="NVARCHAR(64)">
<constraints nullable="false"/>
</column>
<column name="ccy_code" type="NVARCHAR(3)"/>
<column name="issuer_name" type="NVARCHAR(255)"/>
<column name="issuer_ref" type="VARBINARY(512)"/>
<column name="owner_name" type="NVARCHAR(255)"/>
<column name="pennies" type="BIGINT"/>
<column name="ccy_code" type="NVARCHAR(3)">
<constraints nullable="false"/>
</column>
<column name="issuer_name" type="NVARCHAR(255)">
<constraints nullable="true"/>
</column>
<column name="issuer_ref" type="VARBINARY(512)">
<constraints nullable="false"/>
</column>
<column name="owner_name" type="NVARCHAR(255)">
<constraints nullable="true"/>
</column>
<column name="pennies" type="BIGINT">
<constraints nullable="false"/>
</column>
</createTable>
<addPrimaryKey columnNames="output_index, transaction_id" constraintName="CONSTRAINT_DC"
@ -39,7 +49,9 @@
<column name="transaction_id" type="NVARCHAR(64)">
<constraints nullable="false"/>
</column>
<column name="participants" type="NVARCHAR(255)"/>
<column name="participants" type="NVARCHAR(255)">
<constraints nullable="true"/>
</column>
</createTable>
</changeSet>

View File

@ -21,14 +21,30 @@
<column name="transaction_id" type="NVARCHAR(64)">
<constraints nullable="false"/>
</column>
<column name="ccy_code" type="NVARCHAR(3)"/>
<column name="face_value" type="BIGINT"/>
<column name="face_value_issuer_key_hash" type="NVARCHAR(130)"/>
<column name="face_value_issuer_ref" type="varbinary(512)"/>
<column name="issuance_key_hash" type="NVARCHAR(130)"/>
<column name="issuance_ref" type="varbinary(255)"/>
<column name="maturity_instant" type="timestamp"/>
<column name="owner_key_hash" type="NVARCHAR(130)"/>
<column name="ccy_code" type="NVARCHAR(3)">
<constraints nullable="false"/>
</column>
<column name="face_value" type="BIGINT">
<constraints nullable="false"/>
</column>
<column name="face_value_issuer_key_hash" type="NVARCHAR(130)">
<constraints nullable="false"/>
</column>
<column name="face_value_issuer_ref" type="varbinary(512)">
<constraints nullable="false"/>
</column>
<column name="issuance_key_hash" type="NVARCHAR(130)">
<constraints nullable="false"/>
</column>
<column name="issuance_ref" type="varbinary(255)">
<constraints nullable="false"/>
</column>
<column name="maturity_instant" type="timestamp">
<constraints nullable="false"/>
</column>
<column name="owner_key_hash" type="NVARCHAR(130)">
<constraints nullable="false"/>
</column>
</createTable>
</changeSet>
<changeSet author="R3.Corda" id="1511451595465-29">

View File

@ -21,14 +21,30 @@
<column name="transaction_id" type="NVARCHAR(64)">
<constraints nullable="false"/>
</column>
<column name="issuer_name" type="NVARCHAR(255)"/>
<column name="issuer_ref" type="VARBINARY(512)"/>
<column name="owner_name" type="NVARCHAR(255)"/>
<column name="quantity" type="BIGINT"/>
<column name="ccy_code" type="NVARCHAR(3)"/>
<column name="face_value_issuer_key_hash" type="NVARCHAR(130)"/>
<column name="face_value_issuer_ref" type="VARBINARY(512)"/>
<column name="maturity_instant" type="TIMESTAMP"/>
<column name="issuer_name" type="NVARCHAR(255)">
<constraints nullable="true"/>
</column>
<column name="issuer_ref" type="VARBINARY(512)">
<constraints nullable="false"/>
</column>
<column name="owner_name" type="NVARCHAR(255)">
<constraints nullable="true"/>
</column>
<column name="quantity" type="BIGINT">
<constraints nullable="false"/>
</column>
<column name="ccy_code" type="NVARCHAR(3)">
<constraints nullable="false"/>
</column>
<column name="face_value_issuer_key_hash" type="NVARCHAR(130)">
<constraints nullable="false"/>
</column>
<column name="face_value_issuer_ref" type="VARBINARY(512)">
<constraints nullable="false"/>
</column>
<column name="maturity_instant" type="TIMESTAMP">
<constraints nullable="false"/>
</column>
</createTable>
<addPrimaryKey columnNames="output_index, transaction_id" constraintName="CONSTRAINT_5"
@ -45,7 +61,9 @@
<column name="transaction_id" type="NVARCHAR(64)">
<constraints nullable="false"/>
</column>
<column name="participants" type="NVARCHAR(255)"/>
<column name="participants" type="NVARCHAR(255)">
<constraints nullable="true"/>
</column>
</createTable>
<addForeignKeyConstraint baseColumnNames="output_index,transaction_id"

View File

@ -27,4 +27,9 @@
</createTable>
</changeSet>
<changeSet id="1525962920" author="R3.Corda">
<addNotNullConstraint tableName="messages" columnName="message_by" columnDataType="NVARCHAR(255)" />
<addNotNullConstraint tableName="messages" columnName="message_value" columnDataType="NVARCHAR(255)" />
</changeSet>
</databaseChangeLog>

View File

@ -66,16 +66,16 @@ class RunOnceService(private val database: CordaPersistence, private val machine
@Id
val id: Char = 'X'
@Column(name = MACHINE_NAME)
@Column(name = MACHINE_NAME, nullable = false)
val machineName = machineNameInit
@Column(name = PID)
@Column(name = PID, nullable = false)
val pid = pidInit
@Column(name = TIMESTAMP)
@Column(name = TIMESTAMP, nullable = false)
val timestamp = timeStampInit
@Column(name = VERSION)
@Column(name = VERSION, nullable = false)
val version = versionInit
}

View File

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

View File

@ -0,0 +1,41 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<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 author="R3.Corda" id="attchments_rename">
<renameTable oldTableName="node_attchments_contracts" newTableName="node_attachments_contracts" />
</changeSet>
<changeSet author="R3.Corda" id="nullability">
<addNotNullConstraint tableName="node_identities" columnName="identity_value" columnDataType="blob" />
<addNotNullConstraint tableName="node_attachments" columnName="content" columnDataType="blob"/>
<addNotNullConstraint tableName="node_attachments_contracts" columnName="contract_class_name" columnDataType="NVARCHAR(255)"/>
<addNotNullConstraint tableName="node_checkpoints" columnName="checkpoint_value" columnDataType="blob"/>
<addNotNullConstraint tableName="node_contract_upgrades" columnName="contract_class_name" columnDataType="NVARCHAR(255)"/>
<addNotNullConstraint tableName="node_message_ids" columnName="insertion_time" columnDataType="timestamp"/>
<addNotNullConstraint tableName="node_message_ids" columnName="sequence_number" columnDataType="BIGINT"/>
<addNotNullConstraint tableName="node_message_retry" columnName="message" columnDataType="blob"/>
<addNotNullConstraint tableName="node_message_retry" columnName="recipients" columnDataType="blob"/>
<addNotNullConstraint tableName="node_named_identities" columnName="pk_hash" columnDataType="NVARCHAR(130)"/>
<addNotNullConstraint tableName="node_our_key_pairs" columnName="private_key" columnDataType="blob"/>
<addNotNullConstraint tableName="node_our_key_pairs" columnName="public_key" columnDataType="blob"/>
<addNotNullConstraint tableName="node_transaction_mappings" columnName="state_machine_run_id" columnDataType="NVARCHAR(36)"/>
<addNotNullConstraint tableName="node_transactions" columnName="transaction_value" columnDataType="blob"/>
<addNotNullConstraint tableName="node_mutual_exclusion" columnName="MACHINE_NAME" columnDataType="NVARCHAR(255)"/>
<addNotNullConstraint tableName="node_mutual_exclusion" columnName="PID" columnDataType="NVARCHAR(255)"/>
<addNotNullConstraint tableName="node_mutual_exclusion" columnName="MUTUAL_EXCLUSION_TIMESTAMP" columnDataType="timestamp"/>
</changeSet>
</databaseChangeLog>

View File

@ -78,6 +78,7 @@
referencedColumnNames="node_info_id" referencedTableName="node_infos"/>
</changeSet>
<changeSet author="R3.Corda" id="remove_host_port_pk">
<!--Delete, in fact, truncates the table-->
<delete tableName="node_infos"/>
<delete tableName="node_link_nodeinfo_party"/>
<delete tableName="node_info_hosts"/>

View File

@ -16,5 +16,6 @@
<include file="migration/node-info.changelog-init.xml"/>
<include file="migration/node-info.changelog-v1.xml"/>
<include file="migration/node-info.changelog-v2.xml"/>
</databaseChangeLog>

View File

@ -0,0 +1,27 @@
<?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: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="1525962920">
<addNotNullConstraint tableName="node_infos" columnName="node_info_hash" columnDataType="NVARCHAR(64)"/>
<addNotNullConstraint tableName="node_infos" columnName="platform_version" columnDataType="INT"/>
<addNotNullConstraint tableName="node_infos" columnName="serial" columnDataType="BIGINT"/>
<dropNotNullConstraint tableName="node_info_hosts" columnName="host" columnDataType="NVARCHAR(255)" />
<dropNotNullConstraint tableName="node_info_hosts" columnName="port" columnDataType="INT" />
<addNotNullConstraint tableName="node_info_party_cert" columnName="owning_key_hash" columnDataType="NVARCHAR(130)"/>
<addNotNullConstraint tableName="node_info_party_cert" columnName="party_cert_binary" columnDataType="blob"/>
</changeSet>
</databaseChangeLog>

View File

@ -15,5 +15,6 @@
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"/>
</databaseChangeLog>

View File

@ -0,0 +1,26 @@
<?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"
logicalFilePath="migration/node-services.changelog-init.xml">
<changeSet author="R3.Corda" id="nullability">
<addNotNullConstraint tableName="node_bft_committed_states" columnName="consuming_transaction_id" columnDataType="NVARCHAR(64)"/>
<addNotNullConstraint tableName="node_notary_committed_states" columnName="consuming_transaction_id" columnDataType="NVARCHAR(64)"/>
<addNotNullConstraint tableName="node_raft_committed_states" columnName="raft_log_index" columnDataType="BIGINT"/>
<addNotNullConstraint tableName="node_raft_committed_states" columnName="consuming_transaction_id" columnDataType="NVARCHAR(64)"/>
</changeSet>
</databaseChangeLog>

View File

@ -16,5 +16,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"/>
</databaseChangeLog>

View File

@ -0,0 +1,21 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<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">
<!--this is needed because pre-v3 states are no longer supported-->
<changeSet author="R3.Corda" id="nullability">
<addNotNullConstraint tableName="vault_fungible_states" columnName="quantity" columnDataType="BIGINT"/>
<addNotNullConstraint tableName="vault_fungible_states" columnName="quantity" columnDataType="BIGINT"/>
<addNotNullConstraint tableName="vault_states" columnName="contract_state_class_name" columnDataType="NVARCHAR(255)"/>
<addNotNullConstraint tableName="vault_states" columnName="notary_name" columnDataType="NVARCHAR(255)"/>
<addNotNullConstraint tableName="vault_states" columnName="recorded_timestamp" columnDataType="timestamp"/>
<addNotNullConstraint tableName="vault_states" columnName="state_status" columnDataType="INT"/>
<addNotNullConstraint tableName="vault_transaction_notes" columnName="note" columnDataType="NVARCHAR(255)"/>
<addNotNullConstraint tableName="vault_transaction_notes" columnName="transaction_id" columnDataType="NVARCHAR(64)"/>
</changeSet>
</databaseChangeLog>

View File

@ -51,4 +51,10 @@
</changeSet>
<changeSet id="nullability" author="R3.Corda">
<addNotNullConstraint tableName="dummy_linear_states" columnName="linear_boolean" columnDataType="BOOLEAN"/>
<addNotNullConstraint tableName="dummy_linear_states" columnName="linear_number" columnDataType="BIGINT"/>
<addNotNullConstraint tableName="dummy_linear_states" columnName="linear_string" columnDataType="NVARCHAR(255)"/>
<addNotNullConstraint tableName="dummy_linear_states" columnName="linear_timestamp" columnDataType="TIMESTAMP"/>
</changeSet>
</databaseChangeLog>

View File

@ -51,4 +51,10 @@
referencedTableName="dummy_linear_states_v2"/>
</changeSet>
<changeSet id="nullability" author="R3.Corda">
<addNotNullConstraint tableName="dummy_linear_states" columnName="linear_boolean" columnDataType="BOOLEAN"/>
<addNotNullConstraint tableName="dummy_linear_states" columnName="linear_number" columnDataType="BIGINT"/>
<addNotNullConstraint tableName="dummy_linear_states" columnName="linear_string" columnDataType="NVARCHAR(255)"/>
<addNotNullConstraint tableName="dummy_linear_states" columnName="linear_timestamp" columnDataType="TIMESTAMP"/>
</changeSet>
</databaseChangeLog>