<?xml version="1.0" encoding="UTF-8"?>
<changelog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="./schema.xsd">
    <changeset id="TAP-952-grant-access:1" author="j0shua" run-always="true">
        <cypherquery>
            <![CDATA[
                MATCH (v:Vendor)
                    WHERE v.id in ['*', 35968, 35970, 35971, 35972, 35974, 35975, 35977, 35976, 35978, 35979, 35980, 35981]

                MATCH (identity:Identity {
                    email: "viktor.svirskiy.sme@sonymusic-pde.com"
                })

                MERGE (inc:IncrementId {nodeName: 'Profile'})
                    ON CREATE SET inc.id = 2
                    ON MATCH SET inc.id = inc.id + 1

                MERGE (identity)-[hp:HAS_PROFILE]->(p:Profile { profileType: 'DocumentsProfile' })
                ON CREATE SET
                    p.createdAt = datetime(),
                    p.uuid = apoc.create.uuid(),
                    p.profileId = inc.id - 1,
                    p.profileName = identity.name,
                    p.fullCatalogAccess = true,
                    p.roles = ['payee_management']
                SET
                    p.updatedBy = 'database/TAP-952-grant-access',
                    p.updatedOn = datetime(),
                    p.lastModifiedAt = datetime(),
                    p.lastModifiedBy = 'database/TAP-952-grant-access',
                    hp.createdAt = datetime(),
                    hp.updatedBy = 'database/TAP-952-grant-access',
                    hp.updatedOn = datetime()

                MERGE (p)-[hat:HAS_ACCESS_TO]->(v)
                SET
                    hat.createdAt = datetime(),
                    hat.updatedOn = datetime(),
                    hat.updatedBy = 'database/TAP-952-grant-access'

                return true;
            ]]>
        </cypherquery>
    </changeset>
</changelog>