<?xml version="1.0" encoding="UTF-8"?>
<changelog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <changeset id="PUB-896_create_m2m_identity:1" author="jbertran" run-on-change="true">
        <cypherquery>
            <![CDATA[
            MERGE (i:Identity {email: "changelog_lambdas_m2m@publishing.io"})
            ON CREATE SET
                i.id = apoc.create.uuid(),
                i.localization = "en",
                i.lastName = "service user",
                i.defaultBrand = "theorchard",
                i.active = "Y",
                i.createdAt = datetime(),
                i.firstName = "m2m",
                i.numberFormat = "us",
                i.name = "changelog lambdas"
            ON MATCH SET
                i.updatedOn = datetime(),
                i.updatedBy = "PUB-896_create_m2m_identity.xml"
        ]]>
        </cypherquery>
    </changeset>
    <changeset id="PUB-896_create_m2m_identity:2" author="jbertran" run-on-change="true">
        <cypherquery>
            <![CDATA[
            MATCH (i:Identity {email: "changelog_lambdas_m2m@publishing.io"})
                MERGE (increment:IncrementId {nodeName: 'Profile'})
                    ON MATCH SET increment.id = increment.id + 1
                CREATE (profile:Profile {
                    profileId: (increment.id-1),
                    profileType: 'PublishingProfile',
                    profileName: 'changelog_lambdas_m2m PublishingProfile',
                    uuid: apoc.create.uuid(),
                    roles: ['admin'],
                    fullCatalogAccess: true
            })
            MERGE (i)-[:HAS_PROFILE]->(profile)
            WITH profile
            MATCH(v:Vendor {id: "*"})
            MERGE (profile)-[:HAS_ACCESS_TO]->(v)
            RETURN profile
        ]]>
        </cypherquery>
    </changeset>
</changelog>