<?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-4648_au_contraire_fs_access:1" author="durukov">
        <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: 'Charlie Millar',
                    roles: ['audience'],
                    fullCatalogAccess: false,
                    uuid: apoc.create.uuid(),
                    createdAt: datetime(),
                    lastModifiedAt: datetime(),
                    createdBy: 'https://theorchard.atlassian.net/browse/FS-4648',
                    updatedBy: 'https://theorchard.atlassian.net/browse/FS-4648'
                })
                WITH profile
                MATCH (i:Identity {id: '2870e0b3-aa28-40a7-8ee7-65b8a4db6ce6' }),
                    (v1:Vendor {id: 792414 })
                MERGE (profile)-[:HAS_ACCESS_TO]->(v1)
                WITH profile,i
                MERGE (i)-[:HAS_PROFILE]->(profile)
            ]]>
        </neo4j:cypher>
    </changeSet>
    <changeSet id="FS-4648_au_contraire_fs_access:2" author="durukov">
        <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: 'Thomas Haimovici',
                    roles: ['audience'],
                    fullCatalogAccess: false,
                    uuid: apoc.create.uuid(),
                    createdAt: datetime(),
                    lastModifiedAt: datetime(),
                    createdBy: 'https://theorchard.atlassian.net/browse/FS-4648',
                    updatedBy: 'https://theorchard.atlassian.net/browse/FS-4648'
                })
                WITH profile
                MATCH (i:Identity {id: 'a9ede5e2-a948-45c0-9889-a91e0ebdfa3f' }),
                    (v1:Vendor {id: 792414 })
                MERGE (profile)-[:HAS_ACCESS_TO]->(v1)
                WITH profile,i
                MERGE (i)-[:HAS_PROFILE]->(profile)
            ]]>
        </neo4j:cypher>
    </changeSet>
    <changeSet id="FS-4648_au_contraire_fs_access:3" author="durukov">
        <neo4j:cypher>
            <![CDATA[
                MATCH (i:Identity {id:"bf7d0970-428a-4d29-8d7a-07323deba4f7"})-[:HAS_PROFILE]-(p:Profile {profileType: "AudienceProfile"})-[]-(v:Vendor)
                WHERE p.profileId = 512810
                DETACH DELETE p
            ]]>
        </neo4j:cypher>
    </changeSet>
    <changeSet id="FS-4648_au_contraire_fs_access:4" author="durukov">
        <neo4j:cypher>
            <![CDATA[
                MATCH (i:Identity {id: 'dc6f0d1e-c8a4-4fd9-a215-b8f1e7dc495c' })
                SET i.email = 'jake@cardiffgiantmgmt.com',
                    i.updatedBy = 'https://theorchard.atlassian.net/browse/FS-4644'
            ]]>
        </neo4j:cypher>
    </changeSet>
</databaseChangeLog>


