<?xml version="1.0" encoding="UTF-8"?>
<changelog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:/var/app/InputFileSchema.xsd">

    <!-- Run it only for prod -->
    <changeset id="KDH-TOUCH-INCLUDES-1" author="npatel" neo4j-server="music-graph" run-always="true">
        <precondition>
            <sqlquery>
                <![CDATA[
                    SELECT DISTINCT pr.id  as PRODUCT_ID
                    FROM FACTS.prod.orchard_product pr
                    LEFT JOIN FACTS.prod.PROJECT_INCLUDES_ORCHARD_PRODUCT rel on pr.id = rel.product_id
                    WHERE rel.product_id is null
                    ;
                ]]>
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                MATCH (:Project)-[rel:INCLUDES]->(pr:Product {id: toInteger(event.PRODUCT_ID)} )
                SET rel.touchedByBackfill = datetime()
                return count(pr) as cnt
            ]]>
        </cypherquery>
    </changeset>

</changelog>
