<?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="KDH-150_backfill_createdAt_subaccount.xml:1" author="npatel" run-always="true">
        <precondition>
            <sqlquery>
                <![CDATA[
                    SELECT to_varchar(s_ar.date_created, 'YYYY-MM-DDTHH24:MI:SS') as DATE_CREATED, s_ar.SUBACCOUNT_ID 
                    FROM facts.prod.SUBACCOUNT as s_neo 
                    INNER JOIN ORCHARD_APP_REPORTING_V2.ART_RELATIONS_PROD_ART_RELATIONS.SUBACCOUNT as s_ar on s_neo.id = s_ar.subaccount_id
                    WHERE s_neo.created_at is null
                    ;
                ]]>
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                MATCH (sa:SubAccount) 
                    where sa.id = event.SUBACCOUNT_ID  AND sa.created_at is null
                SET sa.createdAt = datetime(event.DATE_CREATED),
                    sa.createdBy = "KDH-150_backfill_createdAt_subaccount",
                    sa.lastModifiedBy = "KDH-150_backfill_createdAt_subaccount",
                    sa.lastModifiedAt = datetime()
            ]]>
        </cypherquery>
    </changeset>
</changelog>
