<?xml version="1.0" encoding="UTF-8"?>
<changelog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:/var/app/InputFileSchema.xsd">
    <changeset id="NO-TICKET_update_awal_default_brands:1" author="aoshomoji" run-on-change="true">
        <precondition>
            <sqlquery>
                <![CDATA[
                    SELECT DISTINCT i.id AS identity_id
                    FROM facts.prod.identity i
                    INNER JOIN facts.prod.has_profile hp ON hp.identity_id = i.id
                    INNER JOIN facts.prod.profile p ON p.uuid = hp.profile_uuid
                    WHERE i.email ILIKE '%@awal.com'
                    AND p.profile_type = 'InsightsProfile'
                    AND i.default_brand <> 'awal'
                ]]>
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                MATCH (i:Identity {id: event.IDENTITY_ID})
                SET i.defaultBrand = 'awal',
                      i.updatedOn = datetime(),
                      i.updatedBy = 'database/NO-TICKET_update_awal_default_brands'
            ]]>
        </cypherquery>
    </changeset>
</changelog>
