<?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-402_label_participant_creation_backfill.xml:1" author="owright" run-on-change="true">
        <query>
            <![CDATA[
                WITH range(0, 70) AS items, 100000 AS step
                UNWIND items AS i
                WITH step AS limit, i * step AS offset
                CALL apoc.periodic.iterate(
                    '
                        MATCH (lp:LabelParticipant)
                        RETURN lp
                        order by lp.id
                        skip $offset  limit $limit
                    '
                    ,
                    '
                        MATCH (lp)-[r:CREATED_FROM]->()
                        WITH lp, min(r.created_at) as earliestCreation
                        SET lp.createdAt = coalesce(lp.createdAt, earliestCreation)
                    ',
                    {batchSize:1000, iterateList:true, parallel:true, concurrency: 5, params:{limit: limit, offset: offset}}
                )
                YIELD total
                RETURN total;
            ]]>
        </query>
    </changeset>
</changelog>
