<?xml version="1.0" encoding="UTF-8"?>
<changelog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.liquigraph.org/schema/1.0/liquigraph.xsd">
    <changeset id="ARTARCH-510_update_artist:1" author="savva" run-on-change="true">
        <query>
            MATCH (masterNode:LabelParticipant {id: 61466712})
            MATCH (otherNode:LabelParticipant)
            WHERE otherNode.id IN [190766166, 193435009]
            WITH masterNode, COLLECT(otherNode) AS otherNodes
            CALL apoc.refactor.mergeNodes(
                [masterNode] + otherNodes,
                {
                    properties: "discard",
                    mergeRels: false
                }
            ) YIELD node
            RETURN true
        </query>
    </changeset>
    <changeset id="ARTARCH-510_update_artist:2" author="savva" run-on-change="true">
        <query>
            MATCH (:LabelParticipant {id: 61466712})-[r:HAS_LABEL_PARTICIPANT]-(:Vendor)
            WITH TAIL(COLLECT(r)) AS duplicates
            UNWIND duplicates AS dup
            DELETE dup
        </query>
    </changeset>
    <changeset id="ARTARCH-510_update_artist:3" author="savva" run-on-change="true">
        <query>
            MATCH (:LabelParticipant {id: 61466712})-[r:HAS_LABEL_PARTICIPANT]-(:Subaccount)
            WITH TAIL(COLLECT(r)) AS duplicates
            UNWIND duplicates AS dup
            DELETE dup
        </query>
    </changeset>
    <changeset id="ARTARCH-510_update_artist:4" author="savva" run-on-change="true">
        <query>
            MATCH (:LabelParticipant {id: 61466712})-[r:CREATED_FROM]-(:ArtistInfo)
            WITH HEAD(COLLECT(r)) AS duplicate
            DELETE duplicate
        </query>
    </changeset>
</changelog>
