<?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="SEC-5425_backfill_profile_id:1" author="bshah" run-on-change="true">
        <query>
            CALL apoc.periodic.iterate(
                "
                    WITH 'mysql_artrelations' as users,
                    '
                        SELECT email, id
                        FROM orchadmin_users
                        WHERE active = \"Y\"
                    ' as sql
                    CALL apoc.load.jdbc(users, sql)
                    YIELD row
                    RETURN row
                ",
                "
                    MATCH (i:Identity)-[:HAS_PROFILE]-(p:Profile) 
                    WHERE i.email = row.email AND p.profileType = 'OrchAdminProfile'
                    SET p.profileId = row.id
                ",
                {batchSize:1000}
            );
        </query>
    </changeset>
</changelog>
