<?xml version="1.0" encoding="UTF-8"?>
<changelog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:/var/app/InputFileSchema.xsd">
    <changeset id="ACC-7600-3_update_schedule_id:1" author="jgetter" run-always="true">
        <precondition>
            <sqlquery>
                <![CDATA[
                   SELECT s.schedule_id AS SCHEDULE_ID, sa.target_id AS CONTRIBUTION_ID
                   FROM ORCHARD_APP_REPORTING_V2.PROD_ROYALTY_ACCOUNTING_ROYALTY_ACCOUNTING.SCHEDULE s
                   JOIN ORCHARD_APP_REPORTING_V2.PROD_ROYALTY_ACCOUNTING_ROYALTY_ACCOUNTING.SCHEDULE_ATTACHMENT sa ON sa.schedule_id=s.schedule_id
                   WHERE sa.target_type='contribution' AND sa.last_modified_by='ACC-7600-1'
                ]]>
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
               MATCH (n:NrContribution {id:event.CONTRIBUTION_ID})
               SET 
                   n.abacusScheduleId=toInteger(event.SCHEDULE_ID),
                   n.lastModifiedAt=datetime(),
                   n.lastModifiedBy='database/ACC-7600-3_update_schedule_id'
            ]]>
        </cypherquery>
    </changeset>
</changelog>
