<?xml version="1.0" encoding="UTF-8"?>
<changelog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="./schema.xsd">
    <changeset id="PLATFORM-3513_backfill_gda_created_vendors_service_tier:1" author="ahan" run-always="true">
        <cypherquery>
            <![CDATA[
                    MATCH (v:Vendor)-[drel:IN_SERVICE_TIER]->(st:ServiceTier)
                        WHERE
                            st.uuid = '1ed7aac0-ceb6-4c09-9166-afda8f349316' and
                            v.source = 'event.gdaApproval' and
                            v.createdAt > datetime({year:2023, month:1})
                        SET drel.updatedOn = localdatetime(),
                            drel.updatedBy = 'Platform-3513-backfill-gda-st'
                        WITH v, drel, st
                            CALL apoc.refactor.setType(drel, 'DELETED_IN_SERVICE_TIER')
                                YIELD input, output

                    MATCH (nst:ServiceTier{uuid: '5f2bd4fc-df94-4f35-97d3-ef23f8573279'})
                    MERGE (v)-[rel:IN_SERVICE_TIER]->(nst)
                    SET rel.createdAt = localdatetime(),
                        rel.createdBy = 'Platform-3513-backfill-gda-st'
                    WITH v, nst
                    OPTIONAL MATCH (v)-[erel:DELETED_IN_SERVICE_TIER]->(nst)
                            DELETE erel
                    RETURN v, nst
            ]]>
        </cypherquery>
    </changeset>
</changelog>
