<?xml version="1.0" encoding="UTF-8"?>
<changelog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <!-- Delete wrong agreement-composition connection and create newcomposition-existing agreement connection -->
    <changeset id="PUB-801_cleanup_songid_7121:1" author="jmarais" run-always="true">
        <cypherquery>
            <![CDATA[
                MATCH (c:PublishingComposition { id: "0387a1a3-fb2f-45ec-ab07-7f68a196ba82" })-[oldRel:HAS_AGREEMENT]-(a:PublishingAgreement { id: "0ba59031-c6ef-4739-822e-d53546564b76" })
                DETACH DELETE a
                WITH c
                MATCH (newA:PublishingAgreement { id: "4a9611d1-4915-4e36-a5fb-3c658057131d" })
                WITH c, newA
                MERGE (c)-[agreementRel:HAS_AGREEMENT]->(newA)
                ON CREATE
                    SET
                        agreementRel.containsPublicDomain = false,
                        agreementRel.containsSample = false,
                        agreementRel.hasLyricsContribution = true,
                        agreementRel.hasMusicContribution = true,
                        agreementRel.split = 50,
                        agreementRel.createdAt = datetime(),
                        agreementRel.lastModifiedAt = datetime(),
                        agreementRel.createdBy = 'database/PUB-801_cleanup_songid_7121',
                        agreementRel.lastModifiedBy = 'database/PUB-801_cleanup_songid_7121'
                RETURN c
            ]]>
        </cypherquery>
    </changeset>
    <!-- Create agreement for non-controlled Melinda S.A. Yellen and connect to composition  -->
    <changeset id="PUB-801_cleanup_songid_7121:2" author="jmarais" run-always="true">
        <cypherquery>
            <![CDATA[
                MATCH (c:PublishingComposition { id: "0387a1a3-fb2f-45ec-ab07-7f68a196ba82" })
                WITH c
                MATCH (a:PublishingAgreement { id: "71edb364-22d3-466e-b860-8f2e1094be05" })
                WITH c, a
                MERGE (c)-[agreementRel:HAS_AGREEMENT]->(a)
                ON CREATE
                    SET
                        agreementRel.containsPublicDomain = false,
                        agreementRel.containsSample = false,
                        agreementRel.hasLyricsContribution = true,
                        agreementRel.hasMusicContribution = true,
                        agreementRel.split = 50,
                        agreementRel.createdAt = datetime(),
                        agreementRel.lastModifiedAt = datetime(),
                        agreementRel.createdBy = 'database/PUB-801_cleanup_songid_7121',
                        agreementRel.lastModifiedBy = 'database/PUB-801_cleanup_songid_7121'
                RETURN c
            ]]>
        </cypherquery>
    </changeset>
</changelog>
