<?xml version="1.0" encoding="UTF-8"?>
<changelog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://www.liquigraph.org/schema/1.0/liquigraph.xsd">
    <changeset id="ARTARCH-655_gp_merge_spotify_ids:1" author="owright" run-on-change="true">
        <query>
            <![CDATA[
                MATCH (gp:GlobalParticipant)
                WITH gp.spotifyId AS spotifyId, collect(gp) AS gps
                WHERE size(gps) > 1
                UNWIND gps AS gp
                WITH *
                ORDER BY gp.createdAt ASC
                WITH gp.spotifyId AS spotifyId, collect(gp) AS gps
                CALL apoc.refactor.mergeNodes(
                    gps,
                    {
                        properties: "discard",
                        mergeRels: true
                    }
                ) YIELD node
                RETURN 0
            ]]>
        </query>
    </changeset>
</changelog>
