<?xml version="1.0" encoding="UTF-8"?>
<changelog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://florent.biville.net/liquigraph/schema/1.0/liquigraph.xsd">
    <changeset id="DOC-161-create_demo_profiles_2:1" author="owright">
        <query>
            <![CDATA[
                WITH [
                    {
                        email: "jchung@theorchard.com",
                        vendorId: 35978
                    }
                ] AS users
                UNWIND range(0, size(users) - 1) AS i
                WITH i, users[i] AS user
                MATCH (identity:Identity {email: user.email})
                MERGE (increment:IncrementId {nodeName: 'Profile'})
                    ON CREATE SET increment.id = 2
                    ON MATCH SET increment.id = increment.id + 1
                CREATE (profile:Profile {
                    brand: 'orchard',
                    profileId: (increment.id - 1 - i),
                    profileType: 'DocumentsProfile',
                    profileName: identity.name,
                    fullCatalogAccess: false,
                    roles: ['payee_management'],
                    uuid: apoc.create.uuid()
                })
                MERGE (identity)-[:HAS_PROFILE]->(profile)
                MERGE (v:Vendor { id: user.vendorId })
                MERGE (profile)-[:HAS_ACCESS_TO]->(v)
            ]]>
        </query>
    </changeset>
</changelog>
