<?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="WAR-1390-create-moneyhub-profile:1" author="anavalu">
        <query>
            MATCH (i:Identity)
            WHERE i.id = '0a007fde-7abd-47a8-aea3-d9915d93c7ad'
            MERGE (increment:IncrementId {nodeName: 'Profile'})
                ON CREATE SET increment.id = 2
                ON MATCH SET increment.id = increment.id + 1
            CREATE (p:Profile {
                profileId: (increment.id-1),
                profileType: 'MoneyhubProfile',
                profileName: i.name,
                uuid: apoc.create.uuid(),
                roles: ['administrator', 'accounting'],
                fullCatalogAccess: true,
                brand: 'orchard',
                createdAt: datetime(),
                lastModifiedAt: datetime(),
                createdBy: 'database/WAR-1390-create-moneyhub-profile:1',
                lastModifiedBy: 'database/WAR-1390-create-moneyhub-profile:1'
            })
            MERGE (i)-[:HAS_PROFILE]->(p)
            WITH p, i
            MATCH (v:Vendor {id: '*'})
            MERGE (p)-[:HAS_ACCESS_TO]->(v)            
            RETURN i,p;
        </query>
    </changeset>
</changelog>
