<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
                   xmlns:neo4j="http://www.liquibase.org/xml/ns/dbchangelog-ext"
                   xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
    <changeSet id="FS-5155_sme_au_sme_nz_access:1" author="ozhovnuvatyi">
        <neo4j:cypher>
            <![CDATA[
                MERGE (increment:IncrementId {nodeName: 'Profile'})
                    ON CREATE SET increment.id = 2
                    ON MATCH SET increment.id = increment.id + 1
                CREATE (profile:Profile {
                    brand: 'sme',
                    profileId: (increment.id-1),
                    profileType: 'AudienceProfile',
                    profileName: 'David Tigar',
                    roles: ['audience'],
                    fullCatalogAccess: false,
                    uuid: apoc.create.uuid(),
                    createdAt: datetime(),
                    lastModifiedAt: datetime(),
                    createdBy: 'https://theorchard.atlassian.net/browse/FS-5155',
                    updatedBy: 'https://theorchard.atlassian.net/browse/FS-5155'
                })
                WITH profile
                MATCH (i:Identity {id: '242a04ac-cfb8-4ee3-be46-e6674b8f11df' }),
                    (v1:Vendor {id: 34578 }),
                    (v2:Vendor {id: 34548 })
                MERGE (profile)-[:HAS_ACCESS_TO]->(v1)
                MERGE (profile)-[:HAS_ACCESS_TO]->(v2)
                WITH profile,i
                MERGE (i)-[:HAS_PROFILE]->(profile)
            ]]>
        </neo4j:cypher>
    </changeSet>
    <changeSet id="FS-5155_sme_au_sme_nz_access:2" author="ozhovnuvatyi">
        <neo4j:cypher>
            <![CDATA[
                MATCH (i:Identity {id: 'e0d25520-83d5-45bf-b0e6-bc485a124f94' })-[:HAS_PROFILE]-(profile:Profile {profileType: "AudienceProfile"}),
                    (v1:Vendor {id: 34578 })
                MERGE (profile)-[:HAS_ACCESS_TO]->(v1)
            ]]>
        </neo4j:cypher>
    </changeSet>
    <changeSet id="FS-5155_sme_au_sme_nz_access:3" author="ozhovnuvatyi">
        <neo4j:cypher>
            <![CDATA[
                MATCH (i:Identity {id: '9f458b3d-b9be-46ec-b52a-615f41eefcf0' })-[:HAS_PROFILE]-(profile:Profile {profileType: "AudienceProfile"}),
                    (v1:Vendor {id: 34578 })
                MERGE (profile)-[:HAS_ACCESS_TO]->(v1)
            ]]>
        </neo4j:cypher>
    </changeSet>
</databaseChangeLog>
