<?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="PLATFORM-2569_profile_uuid_trigger:1" author="npatel">
        <!-- For new Profiles.   COALESCE so it never resets new even when the label changes. -->
        <query>
            CALL apoc.trigger.add(
                'setProfileUUID',
                'UNWIND apoc.trigger.nodesByLabel($assignedLabels, "Profile") AS n SET n.uuid = COALESCE(n.uuid, apoc.create.uuid())',
                {phase: 'before'}
            );
        </query>
        <!-- Backfill -->
        <query>
            MATCH (p:Profile) WHERE p.uuid is null SET p.uuid = apoc.create.uuid();
        </query>
       
    </changeset>
</changelog>
