<?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="DATA-8895_remove_deleted_relationships:1" author="veixar" run-on-change="true">
        <query>
            <![CDATA[
                CALL apoc.periodic.iterate(
                    "
                        MATCH (gp:GlobalParticipant)-[r:DELETED_REPRESENTS]->(pp:PublicParticipant)
                        RETURN gp, pp, r
                    ",
                    "
                        MERGE (gp)-[:REPRESENTS]->(pp)
                        DELETE r
                     ",
                    {batchSize:1000, iterateList:true, parallel:false}
                )
                YIELD total, failedOperations, errorMessages
                CALL apoc.util.validate(failedOperations > 0, "At least one sub-operation failed: %s", [reduce(all_errors = "", error IN keys(errorMessages) | all_errors + ", " + error)])
                RETURN total;
            ]]>
        </query>
    </changeset>
</changelog>
