<?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="1511451595465-3">
        <createTable tableName="cp_states">
            <column name="output_index" type="INT">
                <constraints nullable="false"/>
            </column>
            <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)"/>
        </createTable>
    </changeSet>
    <changeSet author="R3.Corda" id="1511451595465-29">
        <addPrimaryKey columnNames="output_index, transaction_id" constraintName="cp_states_pkey" tableName="cp_states"/>
    </changeSet>
    <changeSet author="R3.Corda" id="1511451595465-52">
        <createIndex indexName="ccy_code_index" tableName="cp_states">
            <column name="ccy_code"/>
        </createIndex>
    </changeSet>
    <changeSet author="R3.Corda" id="1511451595465-54">
        <createIndex indexName="face_value_index" tableName="cp_states">
            <column name="face_value"/>
        </createIndex>
    </changeSet>
    <changeSet author="R3.Corda" id="1511451595465-56">
        <createIndex indexName="maturity_index" tableName="cp_states">
            <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>
