<?xml version="1.0" encoding="UTF-8"?>
<changelog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://www.liquigraph.org/schema/1.0/liquigraph.xsd">
    <changeset id="KDH-156_vendor_to_d3_p1:1" author="ssavva" run-always="true">
        <precondition>
            <sqlquery>
                SELECT PROJECT_ID
                FROM orchard_app_reporting_v2.art_relations_prod_art_relations.project
                WHERE project_id in (2060451, 2342055, 2638957, 2684669, 2692191, 2802276, 3126018, 3352634, 3444746, 3456521, 3478722, 3704667, 3716455, 3735783, 3761341, 3765717, 3767347, 3770815, 3770838, 3777958, 3777999, 3782273, 3789966, 3790470, 3815184, 3832406, 3839103, 3868869, 3877746, 3892358, 3941889, 3941890, 3954812, 3966784, 3979638, 4000241, 4118273, 4120864, 4170541, 4180123, 4184908, 4189354, 4192264, 4193190, 4193500, 4193604, 4196568, 4201785, 4203535, 4206802, 4206820, 4210050, 4210786, 4223078, 4234055, 4252394, 4265086, 4285504, 4286016, 4289417, 4295449, 4306434, 4308288, 4308707, 4312254, 4335874, 4336456, 4352944, 4356242, 4373891, 4374542, 4385980, 4387123, 4413370, 4416681, 4430076, 4451705, 4470788, 4474481, 4532359, 4540137, 4562763, 4567630, 4585083, 4585786, 4597507, 4597706, 4613290, 4619794, 4627901, 4651580, 4689918, 4692720, 4694319, 4694367, 4714015, 4720869, 4729169, 4739211, 4772184, 4784138, 4788021, 4790660, 4792801, 4817658, 4817748, 4817749, 4824424, 4825474, 4825489, 4826687, 4836316, 4838241, 4839685, 4840024, 4847580, 4859641, 4864213, 4869383, 4871603, 5025256, 5026963, 5026964, 5026977, 5026997, 5028204, 5029039, 5029051, 5029060, 5029170, 5029190, 5029192, 5029194, 5029199, 5029203, 5029818, 5029855, 5029856, 5036411, 5043969, 5044533, 5045572, 5045598, 5046131, 5048886, 5052766, 5055933, 5058491, 5059476, 5059699, 5060273, 5060764, 5061383, 5063697, 5065109, 5065694, 5066872, 5067717, 5070691, 5070698, 5072578, 5074491, 5080100, 5080445, 5080450, 5080457, 5081345, 5089396, 5108192, 5108209, 5112558, 5122354, 5122708, 5240644, 5241898, 5241909, 5242445, 5243237, 5244865, 5245058, 5253097, 5258426, 5259143, 5263419, 5265506, 5269047, 5270474, 5272591, 5275533, 5279062, 5279067, 5282112, 5282113, 5287542, 5294541, 5299177, 5305641, 5306255, 5306265, 5306290, 5308151, 5308452, 5312062, 5312114, 5312129, 5313134, 5315213, 5317757, 5319698, 5320256, 5321006, 5321224, 5323923, 5325472, 5326613, 5326975, 5328653, 5328684, 5330019, 5330160, 5330167, 5330175, 5330200, 5334608, 5353979, 5355416, 5361220, 5361263, 5362399, 5362444, 5363094, 5363100, 5364333, 5366810, 5366873, 5370840, 5375299, 5375352, 5376567, 5387741, 5392262, 5392872, 5398765, 5399614, 5416006, 5416185, 5416190, 5416594, 5421028, 5421604, 5428138, 5428185, 5428572, 5444923, 5444998, 5451816, 5455880, 5455904, 5458247, 5459449, 5459995, 5462427, 5466755, 5471339, 5471371, 5471380, 5471452, 5487271, 5493463, 5500150, 5502377, 5522186, 5542190, 5550438, 5550446, 5608681, 5619915, 5623882, 5633550, 5633554, 5633602, 5633607, 5633611, 5633612, 5633627, 5633633, 5633635, 5633637, 5633644, 5633651, 5633654, 5633656, 5633660, 5634497, 5644725, 5644732, 5644734)
                ORDER BY project_id;
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                CALL apoc.periodic.iterate(
                "
                    MATCH (pr:Project {id: $project_id})-[:INCLUDES]->(:Product)-[:INCLUDES]->(:Track)<-[:PARTICIPATED_IN]-(lp:LabelParticipant)<-[gpToLp:REPRESENTS]-(gp:GlobalParticipant)
                    WHERE lp.subaccountId <> pr.subaccountId
                    RETURN pr, lp, gpToLp, gp;
                ",
                "
                    CALL apoc.util.sleep(1)
                    MERGE (nlp:LabelParticipant:Orchard {normalizedName: lp.normalizedName, vendorId: lp.vendorId, subaccountId: pr.subaccountId})
                        ON CREATE SET
                            nlp.id = datetime.realtime().epochMillis,
                            nlp.uuid = apoc.create.uuid(),
                            nlp.createdAt = datetime(),
                            nlp.createdBy = 'database/KDH-156_vendor_to_d3_p1:1'
                        SET nlp += apoc.map.removeKeys(lp, ['id', 'uuid', 'vendorId', 'subaccountId', 'createdAt', 'createdBy']),
                            nlp.lastModifiedAt = datetime(),
                            nlp.lastModifiedBy = 'database/KDH-156_vendor_to_d3_p1:1'
                    WITH *
                    CALL apoc.merge.relationship(gp, type(gpToLp), null, gpToLp, nlp)
                    YIELD rel AS rel
                    RETURN nlp as labelParticipant;
                ",
                {batchSize:1, iterateList:true, parallel:false, params: {project_id: toInteger(event.PROJECT_ID)}}
                )
                YIELD total, failedOperations, errorMessages, failedBatches, batch
                RETURN total, failedOperations, errorMessages, failedBatches, batch;
            ]]>
        </cypherquery>
    </changeset>
    <changeset id="KDH-156_vendor_to_d3_p1:2" author="ssavva" run-always="true">
        <precondition>
            <sqlquery>
                SELECT PROJECT_ID
                FROM orchard_app_reporting_v2.art_relations_prod_art_relations.project
                WHERE project_id in (2060451, 2342055, 2638957, 2684669, 2692191, 2802276, 3126018, 3352634, 3444746, 3456521, 3478722, 3704667, 3716455, 3735783, 3761341, 3765717, 3767347, 3770815, 3770838, 3777958, 3777999, 3782273, 3789966, 3790470, 3815184, 3832406, 3839103, 3868869, 3877746, 3892358, 3941889, 3941890, 3954812, 3966784, 3979638, 4000241, 4118273, 4120864, 4170541, 4180123, 4184908, 4189354, 4192264, 4193190, 4193500, 4193604, 4196568, 4201785, 4203535, 4206802, 4206820, 4210050, 4210786, 4223078, 4234055, 4252394, 4265086, 4285504, 4286016, 4289417, 4295449, 4306434, 4308288, 4308707, 4312254, 4335874, 4336456, 4352944, 4356242, 4373891, 4374542, 4385980, 4387123, 4413370, 4416681, 4430076, 4451705, 4470788, 4474481, 4532359, 4540137, 4562763, 4567630, 4585083, 4585786, 4597507, 4597706, 4613290, 4619794, 4627901, 4651580, 4689918, 4692720, 4694319, 4694367, 4714015, 4720869, 4729169, 4739211, 4772184, 4784138, 4788021, 4790660, 4792801, 4817658, 4817748, 4817749, 4824424, 4825474, 4825489, 4826687, 4836316, 4838241, 4839685, 4840024, 4847580, 4859641, 4864213, 4869383, 4871603, 5025256, 5026963, 5026964, 5026977, 5026997, 5028204, 5029039, 5029051, 5029060, 5029170, 5029190, 5029192, 5029194, 5029199, 5029203, 5029818, 5029855, 5029856, 5036411, 5043969, 5044533, 5045572, 5045598, 5046131, 5048886, 5052766, 5055933, 5058491, 5059476, 5059699, 5060273, 5060764, 5061383, 5063697, 5065109, 5065694, 5066872, 5067717, 5070691, 5070698, 5072578, 5074491, 5080100, 5080445, 5080450, 5080457, 5081345, 5089396, 5108192, 5108209, 5112558, 5122354, 5122708, 5240644, 5241898, 5241909, 5242445, 5243237, 5244865, 5245058, 5253097, 5258426, 5259143, 5263419, 5265506, 5269047, 5270474, 5272591, 5275533, 5279062, 5279067, 5282112, 5282113, 5287542, 5294541, 5299177, 5305641, 5306255, 5306265, 5306290, 5308151, 5308452, 5312062, 5312114, 5312129, 5313134, 5315213, 5317757, 5319698, 5320256, 5321006, 5321224, 5323923, 5325472, 5326613, 5326975, 5328653, 5328684, 5330019, 5330160, 5330167, 5330175, 5330200, 5334608, 5353979, 5355416, 5361220, 5361263, 5362399, 5362444, 5363094, 5363100, 5364333, 5366810, 5366873, 5370840, 5375299, 5375352, 5376567, 5387741, 5392262, 5392872, 5398765, 5399614, 5416006, 5416185, 5416190, 5416594, 5421028, 5421604, 5428138, 5428185, 5428572, 5444923, 5444998, 5451816, 5455880, 5455904, 5458247, 5459449, 5459995, 5462427, 5466755, 5471339, 5471371, 5471380, 5471452, 5487271, 5493463, 5500150, 5502377, 5522186, 5542190, 5550438, 5550446, 5608681, 5619915, 5623882, 5633550, 5633554, 5633602, 5633607, 5633611, 5633612, 5633627, 5633633, 5633635, 5633637, 5633644, 5633651, 5633654, 5633656, 5633660, 5634497, 5644725, 5644732, 5644734)
                ORDER BY project_id;
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                CALL apoc.periodic.iterate(
                "
                    MATCH (pr:Project {id: $project_id})-[:INCLUDES]->(:Product)-[:INCLUDES]->(t:Track)-[lpToT]-(lp:LabelParticipant)-[cf:CREATED_FROM]->(ai:ArtistInfo)
                    WHERE lp.subaccountId <> pr.subaccountId
                    RETURN pr, lp, cf, ai
                ",
                "
                CALL apoc.util.sleep(1)
                MERGE (nlp:LabelParticipant:Orchard {name: lp.name, vendorId: lp.vendorId, subaccountId: pr.subaccountId})
                    ON CREATE SET
                        nlp.id = datetime.realtime().epochMillis,
                        nlp.uuid = apoc.create.uuid(),
                        nlp.createdAt = datetime(),
                        nlp.createdBy = 'database/KDH-156_vendor_to_d3_p1:2'
                    SET nlp += apoc.map.removeKeys(lp, ['id', 'uuid', 'vendorId', 'subaccountId', 'createdAt', 'createdBy']),
                        nlp.lastModifiedAt = datetime(),
                        nlp.lastModifiedBy = 'database/KDH-156_vendor_to_d3_p1:2'
                WITH *
                CALL apoc.merge.relationship(nlp, type(cf), null, cf, ai)
                YIELD rel AS rel
                RETURN nlp as labelParticipant",
                  {batchSize:1, iterateList:true, parallel:false, params: {project_id: toInteger(event.PROJECT_ID)}}
                )
                YIELD total, failedOperations, errorMessages, failedBatches, batch
                RETURN total, failedOperations, errorMessages, failedBatches, batch;
            ]]>
        </cypherquery>
    </changeset>
    <changeset id="KDH-156_vendor_to_d3_p1:3" author="ssavva" run-always="true">
        <precondition>
            <sqlquery>
                SELECT PROJECT_ID
                FROM orchard_app_reporting_v2.art_relations_prod_art_relations.project
                WHERE project_id in (2060451, 2342055, 2638957, 2684669, 2692191, 2802276, 3126018, 3352634, 3444746, 3456521, 3478722, 3704667, 3716455, 3735783, 3761341, 3765717, 3767347, 3770815, 3770838, 3777958, 3777999, 3782273, 3789966, 3790470, 3815184, 3832406, 3839103, 3868869, 3877746, 3892358, 3941889, 3941890, 3954812, 3966784, 3979638, 4000241, 4118273, 4120864, 4170541, 4180123, 4184908, 4189354, 4192264, 4193190, 4193500, 4193604, 4196568, 4201785, 4203535, 4206802, 4206820, 4210050, 4210786, 4223078, 4234055, 4252394, 4265086, 4285504, 4286016, 4289417, 4295449, 4306434, 4308288, 4308707, 4312254, 4335874, 4336456, 4352944, 4356242, 4373891, 4374542, 4385980, 4387123, 4413370, 4416681, 4430076, 4451705, 4470788, 4474481, 4532359, 4540137, 4562763, 4567630, 4585083, 4585786, 4597507, 4597706, 4613290, 4619794, 4627901, 4651580, 4689918, 4692720, 4694319, 4694367, 4714015, 4720869, 4729169, 4739211, 4772184, 4784138, 4788021, 4790660, 4792801, 4817658, 4817748, 4817749, 4824424, 4825474, 4825489, 4826687, 4836316, 4838241, 4839685, 4840024, 4847580, 4859641, 4864213, 4869383, 4871603, 5025256, 5026963, 5026964, 5026977, 5026997, 5028204, 5029039, 5029051, 5029060, 5029170, 5029190, 5029192, 5029194, 5029199, 5029203, 5029818, 5029855, 5029856, 5036411, 5043969, 5044533, 5045572, 5045598, 5046131, 5048886, 5052766, 5055933, 5058491, 5059476, 5059699, 5060273, 5060764, 5061383, 5063697, 5065109, 5065694, 5066872, 5067717, 5070691, 5070698, 5072578, 5074491, 5080100, 5080445, 5080450, 5080457, 5081345, 5089396, 5108192, 5108209, 5112558, 5122354, 5122708, 5240644, 5241898, 5241909, 5242445, 5243237, 5244865, 5245058, 5253097, 5258426, 5259143, 5263419, 5265506, 5269047, 5270474, 5272591, 5275533, 5279062, 5279067, 5282112, 5282113, 5287542, 5294541, 5299177, 5305641, 5306255, 5306265, 5306290, 5308151, 5308452, 5312062, 5312114, 5312129, 5313134, 5315213, 5317757, 5319698, 5320256, 5321006, 5321224, 5323923, 5325472, 5326613, 5326975, 5328653, 5328684, 5330019, 5330160, 5330167, 5330175, 5330200, 5334608, 5353979, 5355416, 5361220, 5361263, 5362399, 5362444, 5363094, 5363100, 5364333, 5366810, 5366873, 5370840, 5375299, 5375352, 5376567, 5387741, 5392262, 5392872, 5398765, 5399614, 5416006, 5416185, 5416190, 5416594, 5421028, 5421604, 5428138, 5428185, 5428572, 5444923, 5444998, 5451816, 5455880, 5455904, 5458247, 5459449, 5459995, 5462427, 5466755, 5471339, 5471371, 5471380, 5471452, 5487271, 5493463, 5500150, 5502377, 5522186, 5542190, 5550438, 5550446, 5608681, 5619915, 5623882, 5633550, 5633554, 5633602, 5633607, 5633611, 5633612, 5633627, 5633633, 5633635, 5633637, 5633644, 5633651, 5633654, 5633656, 5633660, 5634497, 5644725, 5644732, 5644734)
                ORDER BY project_id;
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                MATCH (pr:Project {id: toInteger(event.PROJECT_ID)})-[:INCLUDES]->(:Product)-[:INCLUDES]->(:Track)<-[:PARTICIPATED_IN]-(lp:LabelParticipant)-[cf:CREATED_FROM]->(:ArtistInfo)
                WHERE lp.subaccountId <> pr.subaccountId
                DELETE cf;
            ]]>
        </cypherquery>
    </changeset>
    <changeset id="KDH-156_vendor_to_d3_p1:4" author="ssavva" run-always="true">
        <precondition>
            <sqlquery>
                SELECT PROJECT_ID
                FROM orchard_app_reporting_v2.art_relations_prod_art_relations.project
                WHERE project_id in (2060451, 2342055, 2638957, 2684669, 2692191, 2802276, 3126018, 3352634, 3444746, 3456521, 3478722, 3704667, 3716455, 3735783, 3761341, 3765717, 3767347, 3770815, 3770838, 3777958, 3777999, 3782273, 3789966, 3790470, 3815184, 3832406, 3839103, 3868869, 3877746, 3892358, 3941889, 3941890, 3954812, 3966784, 3979638, 4000241, 4118273, 4120864, 4170541, 4180123, 4184908, 4189354, 4192264, 4193190, 4193500, 4193604, 4196568, 4201785, 4203535, 4206802, 4206820, 4210050, 4210786, 4223078, 4234055, 4252394, 4265086, 4285504, 4286016, 4289417, 4295449, 4306434, 4308288, 4308707, 4312254, 4335874, 4336456, 4352944, 4356242, 4373891, 4374542, 4385980, 4387123, 4413370, 4416681, 4430076, 4451705, 4470788, 4474481, 4532359, 4540137, 4562763, 4567630, 4585083, 4585786, 4597507, 4597706, 4613290, 4619794, 4627901, 4651580, 4689918, 4692720, 4694319, 4694367, 4714015, 4720869, 4729169, 4739211, 4772184, 4784138, 4788021, 4790660, 4792801, 4817658, 4817748, 4817749, 4824424, 4825474, 4825489, 4826687, 4836316, 4838241, 4839685, 4840024, 4847580, 4859641, 4864213, 4869383, 4871603, 5025256, 5026963, 5026964, 5026977, 5026997, 5028204, 5029039, 5029051, 5029060, 5029170, 5029190, 5029192, 5029194, 5029199, 5029203, 5029818, 5029855, 5029856, 5036411, 5043969, 5044533, 5045572, 5045598, 5046131, 5048886, 5052766, 5055933, 5058491, 5059476, 5059699, 5060273, 5060764, 5061383, 5063697, 5065109, 5065694, 5066872, 5067717, 5070691, 5070698, 5072578, 5074491, 5080100, 5080445, 5080450, 5080457, 5081345, 5089396, 5108192, 5108209, 5112558, 5122354, 5122708, 5240644, 5241898, 5241909, 5242445, 5243237, 5244865, 5245058, 5253097, 5258426, 5259143, 5263419, 5265506, 5269047, 5270474, 5272591, 5275533, 5279062, 5279067, 5282112, 5282113, 5287542, 5294541, 5299177, 5305641, 5306255, 5306265, 5306290, 5308151, 5308452, 5312062, 5312114, 5312129, 5313134, 5315213, 5317757, 5319698, 5320256, 5321006, 5321224, 5323923, 5325472, 5326613, 5326975, 5328653, 5328684, 5330019, 5330160, 5330167, 5330175, 5330200, 5334608, 5353979, 5355416, 5361220, 5361263, 5362399, 5362444, 5363094, 5363100, 5364333, 5366810, 5366873, 5370840, 5375299, 5375352, 5376567, 5387741, 5392262, 5392872, 5398765, 5399614, 5416006, 5416185, 5416190, 5416594, 5421028, 5421604, 5428138, 5428185, 5428572, 5444923, 5444998, 5451816, 5455880, 5455904, 5458247, 5459449, 5459995, 5462427, 5466755, 5471339, 5471371, 5471380, 5471452, 5487271, 5493463, 5500150, 5502377, 5522186, 5542190, 5550438, 5550446, 5608681, 5619915, 5623882, 5633550, 5633554, 5633602, 5633607, 5633611, 5633612, 5633627, 5633633, 5633635, 5633637, 5633644, 5633651, 5633654, 5633656, 5633660, 5634497, 5644725, 5644732, 5644734)
                ORDER BY project_id;
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                CALL apoc.periodic.iterate(
                "
                    MATCH (pr:Project {id: $project_id})-[:INCLUDES]->(:Product)-[:INCLUDES]->(t:Track)<-[lpToT:PARTICIPATED_IN]-(lp:LabelParticipant)
                    WHERE lp.subaccountId <> pr.subaccountId
                    RETURN pr, lp, lpToT, t
                ",
                "
                    CALL apoc.util.sleep(1)
                    MERGE (nlp:LabelParticipant:Orchard {normalizedName: lp.normalizedName, vendorId: pr.vendorId, subaccountId: pr.subaccountId})
                        ON CREATE SET
                            nlp.id = datetime.realtime().epochMillis,
                            nlp.uuid = apoc.create.uuid(),
                            nlp.createdAt = datetime(),
                            nlp.createdBy = 'database/KDH-156_vendor_to_d3_p1:4'
                        SET nlp += apoc.map.removeKeys(lp, ['id', 'uuid', 'vendorId', 'subaccountId', 'createdAt', 'createdBy']),
                            nlp.lastModifiedAt = datetime(),
                            nlp.lastModifiedBy = 'database/KDH-156_vendor_to_d3_p1:4'
                    WITH *
                    CALL apoc.merge.relationship(nlp, type(lpToT), {participated_as: lpToT.participated_as}, lpToT, t)
                    YIELD rel AS rel1
                    RETURN nlp as labelParticipant
                ",
                {batchSize:1, iterateList:true, parallel:false, params: {project_id: toInteger(event.PROJECT_ID)}}
                )
                YIELD total, failedOperations, errorMessages, failedBatches, batch
                RETURN total, failedOperations, errorMessages, failedBatches, batch;
            ]]>
        </cypherquery>
    </changeset>
    <changeset id="KDH-156_vendor_to_d3_p1:5" author="ssavva" run-always="true">
        <precondition>
            <sqlquery>
                SELECT PROJECT_ID
                FROM orchard_app_reporting_v2.art_relations_prod_art_relations.project
                WHERE project_id in (2060451, 2342055, 2638957, 2684669, 2692191, 2802276, 3126018, 3352634, 3444746, 3456521, 3478722, 3704667, 3716455, 3735783, 3761341, 3765717, 3767347, 3770815, 3770838, 3777958, 3777999, 3782273, 3789966, 3790470, 3815184, 3832406, 3839103, 3868869, 3877746, 3892358, 3941889, 3941890, 3954812, 3966784, 3979638, 4000241, 4118273, 4120864, 4170541, 4180123, 4184908, 4189354, 4192264, 4193190, 4193500, 4193604, 4196568, 4201785, 4203535, 4206802, 4206820, 4210050, 4210786, 4223078, 4234055, 4252394, 4265086, 4285504, 4286016, 4289417, 4295449, 4306434, 4308288, 4308707, 4312254, 4335874, 4336456, 4352944, 4356242, 4373891, 4374542, 4385980, 4387123, 4413370, 4416681, 4430076, 4451705, 4470788, 4474481, 4532359, 4540137, 4562763, 4567630, 4585083, 4585786, 4597507, 4597706, 4613290, 4619794, 4627901, 4651580, 4689918, 4692720, 4694319, 4694367, 4714015, 4720869, 4729169, 4739211, 4772184, 4784138, 4788021, 4790660, 4792801, 4817658, 4817748, 4817749, 4824424, 4825474, 4825489, 4826687, 4836316, 4838241, 4839685, 4840024, 4847580, 4859641, 4864213, 4869383, 4871603, 5025256, 5026963, 5026964, 5026977, 5026997, 5028204, 5029039, 5029051, 5029060, 5029170, 5029190, 5029192, 5029194, 5029199, 5029203, 5029818, 5029855, 5029856, 5036411, 5043969, 5044533, 5045572, 5045598, 5046131, 5048886, 5052766, 5055933, 5058491, 5059476, 5059699, 5060273, 5060764, 5061383, 5063697, 5065109, 5065694, 5066872, 5067717, 5070691, 5070698, 5072578, 5074491, 5080100, 5080445, 5080450, 5080457, 5081345, 5089396, 5108192, 5108209, 5112558, 5122354, 5122708, 5240644, 5241898, 5241909, 5242445, 5243237, 5244865, 5245058, 5253097, 5258426, 5259143, 5263419, 5265506, 5269047, 5270474, 5272591, 5275533, 5279062, 5279067, 5282112, 5282113, 5287542, 5294541, 5299177, 5305641, 5306255, 5306265, 5306290, 5308151, 5308452, 5312062, 5312114, 5312129, 5313134, 5315213, 5317757, 5319698, 5320256, 5321006, 5321224, 5323923, 5325472, 5326613, 5326975, 5328653, 5328684, 5330019, 5330160, 5330167, 5330175, 5330200, 5334608, 5353979, 5355416, 5361220, 5361263, 5362399, 5362444, 5363094, 5363100, 5364333, 5366810, 5366873, 5370840, 5375299, 5375352, 5376567, 5387741, 5392262, 5392872, 5398765, 5399614, 5416006, 5416185, 5416190, 5416594, 5421028, 5421604, 5428138, 5428185, 5428572, 5444923, 5444998, 5451816, 5455880, 5455904, 5458247, 5459449, 5459995, 5462427, 5466755, 5471339, 5471371, 5471380, 5471452, 5487271, 5493463, 5500150, 5502377, 5522186, 5542190, 5550438, 5550446, 5608681, 5619915, 5623882, 5633550, 5633554, 5633602, 5633607, 5633611, 5633612, 5633627, 5633633, 5633635, 5633637, 5633644, 5633651, 5633654, 5633656, 5633660, 5634497, 5644725, 5644732, 5644734)
                ORDER BY project_id;
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                CALL apoc.periodic.iterate(
                "
                    MATCH (pr:Project {id: $project_id})-[:INCLUDES]->(:Product)-[:INCLUDES]->(t:Track)<-[:PARTICIPATED_IN]-(lp:LabelParticipant)
                    WHERE lp.subaccountId <> pr.subaccountId
                    MATCH (lp)-[cf:CREATED_FROM]->(ta:TrackArtist)<-[:HAS_SOURCE_ARTIST]-(t)
                    RETURN pr, lp, cf, ta
                ",
                "
                    CALL apoc.util.sleep(1)
                    MERGE (nlp:LabelParticipant:Orchard {normalizedName: lp.normalizedName, vendorId: lp.vendorId, subaccountId: pr.subaccountId})
                        ON CREATE SET
                            nlp.id = datetime.realtime().epochMillis,
                            nlp.uuid = apoc.create.uuid(),
                            nlp.createdAt = datetime(),
                            nlp.createdBy = 'database/KDH-156_vendor_to_d3_p1:5'
                        SET nlp += apoc.map.removeKeys(lp, ['id', 'uuid', 'vendorId', 'subaccountId', 'createdAt', 'createdBy']),
                            nlp.lastModifiedAt = datetime(),
                            nlp.lastModifiedBy = 'database/KDH-156_vendor_to_d3_p1:5'
                    WITH *
                    CALL apoc.merge.relationship(nlp, type(cf), null, cf, ta)
                    YIELD rel AS rel
                    RETURN nlp as labelParticipant
                ",
                {batchSize:1, iterateList:true, parallel:false, params: {project_id: toInteger(event.PROJECT_ID)}}
                )
                YIELD total, failedOperations, errorMessages, failedBatches, batch
                RETURN total, failedOperations, errorMessages, failedBatches, batch;
            ]]>
        </cypherquery>
    </changeset>
    <changeset id="KDH-156_vendor_to_d3_p1:6" author="ssavva" run-always="true">
        <precondition>
            <sqlquery>
                SELECT PROJECT_ID
                FROM orchard_app_reporting_v2.art_relations_prod_art_relations.project
                WHERE project_id in (2060451, 2342055, 2638957, 2684669, 2692191, 2802276, 3126018, 3352634, 3444746, 3456521, 3478722, 3704667, 3716455, 3735783, 3761341, 3765717, 3767347, 3770815, 3770838, 3777958, 3777999, 3782273, 3789966, 3790470, 3815184, 3832406, 3839103, 3868869, 3877746, 3892358, 3941889, 3941890, 3954812, 3966784, 3979638, 4000241, 4118273, 4120864, 4170541, 4180123, 4184908, 4189354, 4192264, 4193190, 4193500, 4193604, 4196568, 4201785, 4203535, 4206802, 4206820, 4210050, 4210786, 4223078, 4234055, 4252394, 4265086, 4285504, 4286016, 4289417, 4295449, 4306434, 4308288, 4308707, 4312254, 4335874, 4336456, 4352944, 4356242, 4373891, 4374542, 4385980, 4387123, 4413370, 4416681, 4430076, 4451705, 4470788, 4474481, 4532359, 4540137, 4562763, 4567630, 4585083, 4585786, 4597507, 4597706, 4613290, 4619794, 4627901, 4651580, 4689918, 4692720, 4694319, 4694367, 4714015, 4720869, 4729169, 4739211, 4772184, 4784138, 4788021, 4790660, 4792801, 4817658, 4817748, 4817749, 4824424, 4825474, 4825489, 4826687, 4836316, 4838241, 4839685, 4840024, 4847580, 4859641, 4864213, 4869383, 4871603, 5025256, 5026963, 5026964, 5026977, 5026997, 5028204, 5029039, 5029051, 5029060, 5029170, 5029190, 5029192, 5029194, 5029199, 5029203, 5029818, 5029855, 5029856, 5036411, 5043969, 5044533, 5045572, 5045598, 5046131, 5048886, 5052766, 5055933, 5058491, 5059476, 5059699, 5060273, 5060764, 5061383, 5063697, 5065109, 5065694, 5066872, 5067717, 5070691, 5070698, 5072578, 5074491, 5080100, 5080445, 5080450, 5080457, 5081345, 5089396, 5108192, 5108209, 5112558, 5122354, 5122708, 5240644, 5241898, 5241909, 5242445, 5243237, 5244865, 5245058, 5253097, 5258426, 5259143, 5263419, 5265506, 5269047, 5270474, 5272591, 5275533, 5279062, 5279067, 5282112, 5282113, 5287542, 5294541, 5299177, 5305641, 5306255, 5306265, 5306290, 5308151, 5308452, 5312062, 5312114, 5312129, 5313134, 5315213, 5317757, 5319698, 5320256, 5321006, 5321224, 5323923, 5325472, 5326613, 5326975, 5328653, 5328684, 5330019, 5330160, 5330167, 5330175, 5330200, 5334608, 5353979, 5355416, 5361220, 5361263, 5362399, 5362444, 5363094, 5363100, 5364333, 5366810, 5366873, 5370840, 5375299, 5375352, 5376567, 5387741, 5392262, 5392872, 5398765, 5399614, 5416006, 5416185, 5416190, 5416594, 5421028, 5421604, 5428138, 5428185, 5428572, 5444923, 5444998, 5451816, 5455880, 5455904, 5458247, 5459449, 5459995, 5462427, 5466755, 5471339, 5471371, 5471380, 5471452, 5487271, 5493463, 5500150, 5502377, 5522186, 5542190, 5550438, 5550446, 5608681, 5619915, 5623882, 5633550, 5633554, 5633602, 5633607, 5633611, 5633612, 5633627, 5633633, 5633635, 5633637, 5633644, 5633651, 5633654, 5633656, 5633660, 5634497, 5644725, 5644732, 5644734)
                ORDER BY project_id;
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                CALL apoc.periodic.iterate(
                "
                    MATCH (pr:Project {id: $project_id})-[:INCLUDES]->(:Product)-[:INCLUDES]->(t:Track)<-[:PARTICIPATED_IN]-(lp:LabelParticipant)
                    WHERE lp.subaccountId <> pr.subaccountId
                    MATCH (lp)-[cf:CREATED_FROM]->(tw:TrackWriter)<-[:HAS_SOURCE_ARTIST]-(t)
                    RETURN pr, lp, cf, tw
                ",
                "
                    CALL apoc.util.sleep(1)
                    MERGE (nlp:LabelParticipant:Orchard {normalizedName: lp.normalizedName, vendorId: lp.vendorId, subaccountId: pr.subaccountId})
                        ON CREATE SET
                            nlp.id = datetime.realtime().epochMillis,
                            nlp.uuid = apoc.create.uuid(),
                            nlp.createdAt = datetime(),
                            nlp.createdBy = 'database/KDH-156_vendor_to_d3_p1:6'
                        SET nlp += apoc.map.removeKeys(lp, ['id', 'uuid', 'vendorId', 'subaccountId', 'createdAt', 'createdBy']),
                            nlp.lastModifiedAt = datetime(),
                            nlp.lastModifiedBy = 'database/KDH-156_vendor_to_d3_p1:6'
                    WITH *
                    CALL apoc.merge.relationship(nlp, type(cf), null, cf, tw)
                    YIELD rel AS rel
                    RETURN nlp as labelParticipant
                ",
                {batchSize:1, iterateList:true, parallel:false, params: {project_id: toInteger(event.PROJECT_ID)}}
                )
                YIELD total, failedOperations, errorMessages, failedBatches, batch
                RETURN total, failedOperations, errorMessages, failedBatches, batch;
            ]]>
        </cypherquery>
    </changeset>
    <changeset id="KDH-156_vendor_to_d3_p1:7" author="ssavva" run-always="true">
        <precondition>
            <sqlquery>
                SELECT PROJECT_ID
                FROM orchard_app_reporting_v2.art_relations_prod_art_relations.project
                WHERE project_id in (2060451, 2342055, 2638957, 2684669, 2692191, 2802276, 3126018, 3352634, 3444746, 3456521, 3478722, 3704667, 3716455, 3735783, 3761341, 3765717, 3767347, 3770815, 3770838, 3777958, 3777999, 3782273, 3789966, 3790470, 3815184, 3832406, 3839103, 3868869, 3877746, 3892358, 3941889, 3941890, 3954812, 3966784, 3979638, 4000241, 4118273, 4120864, 4170541, 4180123, 4184908, 4189354, 4192264, 4193190, 4193500, 4193604, 4196568, 4201785, 4203535, 4206802, 4206820, 4210050, 4210786, 4223078, 4234055, 4252394, 4265086, 4285504, 4286016, 4289417, 4295449, 4306434, 4308288, 4308707, 4312254, 4335874, 4336456, 4352944, 4356242, 4373891, 4374542, 4385980, 4387123, 4413370, 4416681, 4430076, 4451705, 4470788, 4474481, 4532359, 4540137, 4562763, 4567630, 4585083, 4585786, 4597507, 4597706, 4613290, 4619794, 4627901, 4651580, 4689918, 4692720, 4694319, 4694367, 4714015, 4720869, 4729169, 4739211, 4772184, 4784138, 4788021, 4790660, 4792801, 4817658, 4817748, 4817749, 4824424, 4825474, 4825489, 4826687, 4836316, 4838241, 4839685, 4840024, 4847580, 4859641, 4864213, 4869383, 4871603, 5025256, 5026963, 5026964, 5026977, 5026997, 5028204, 5029039, 5029051, 5029060, 5029170, 5029190, 5029192, 5029194, 5029199, 5029203, 5029818, 5029855, 5029856, 5036411, 5043969, 5044533, 5045572, 5045598, 5046131, 5048886, 5052766, 5055933, 5058491, 5059476, 5059699, 5060273, 5060764, 5061383, 5063697, 5065109, 5065694, 5066872, 5067717, 5070691, 5070698, 5072578, 5074491, 5080100, 5080445, 5080450, 5080457, 5081345, 5089396, 5108192, 5108209, 5112558, 5122354, 5122708, 5240644, 5241898, 5241909, 5242445, 5243237, 5244865, 5245058, 5253097, 5258426, 5259143, 5263419, 5265506, 5269047, 5270474, 5272591, 5275533, 5279062, 5279067, 5282112, 5282113, 5287542, 5294541, 5299177, 5305641, 5306255, 5306265, 5306290, 5308151, 5308452, 5312062, 5312114, 5312129, 5313134, 5315213, 5317757, 5319698, 5320256, 5321006, 5321224, 5323923, 5325472, 5326613, 5326975, 5328653, 5328684, 5330019, 5330160, 5330167, 5330175, 5330200, 5334608, 5353979, 5355416, 5361220, 5361263, 5362399, 5362444, 5363094, 5363100, 5364333, 5366810, 5366873, 5370840, 5375299, 5375352, 5376567, 5387741, 5392262, 5392872, 5398765, 5399614, 5416006, 5416185, 5416190, 5416594, 5421028, 5421604, 5428138, 5428185, 5428572, 5444923, 5444998, 5451816, 5455880, 5455904, 5458247, 5459449, 5459995, 5462427, 5466755, 5471339, 5471371, 5471380, 5471452, 5487271, 5493463, 5500150, 5502377, 5522186, 5542190, 5550438, 5550446, 5608681, 5619915, 5623882, 5633550, 5633554, 5633602, 5633607, 5633611, 5633612, 5633627, 5633633, 5633635, 5633637, 5633644, 5633651, 5633654, 5633656, 5633660, 5634497, 5644725, 5644732, 5644734)
                ORDER BY project_id;
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                MATCH (pr:Project {id: toInteger(event.PROJECT_ID)})-[:INCLUDES]->(:Product)-[:INCLUDES]->(t:Track)<-[lpToT:PARTICIPATED_IN]-(lp:LabelParticipant)
                WHERE lp.subaccountId <> pr.subaccountId
                OPTIONAL MATCH (lp)-[lpToTa:CREATED_FROM]->(:TrackArtist)<-[:HAS_SOURCE_ARTIST]-(t)
                OPTIONAL MATCH (lp)-[lpToTw:CREATED_FROM]->(:TrackWriter)<-[:HAS_SOURCE_ARTIST]-(t)
                DELETE lpToT, lpToTa, lpToTw;
            ]]>
        </cypherquery>
    </changeset>
    <changeset id="KDH-156_vendor_to_d3_p1:8" author="ssavva" run-always="true">
        <precondition>
            <sqlquery>
                SELECT PROJECT_ID
                FROM orchard_app_reporting_v2.art_relations_prod_art_relations.project
                WHERE project_id in (2060451, 2342055, 2638957, 2684669, 2692191, 2802276, 3126018, 3352634, 3444746, 3456521, 3478722, 3704667, 3716455, 3735783, 3761341, 3765717, 3767347, 3770815, 3770838, 3777958, 3777999, 3782273, 3789966, 3790470, 3815184, 3832406, 3839103, 3868869, 3877746, 3892358, 3941889, 3941890, 3954812, 3966784, 3979638, 4000241, 4118273, 4120864, 4170541, 4180123, 4184908, 4189354, 4192264, 4193190, 4193500, 4193604, 4196568, 4201785, 4203535, 4206802, 4206820, 4210050, 4210786, 4223078, 4234055, 4252394, 4265086, 4285504, 4286016, 4289417, 4295449, 4306434, 4308288, 4308707, 4312254, 4335874, 4336456, 4352944, 4356242, 4373891, 4374542, 4385980, 4387123, 4413370, 4416681, 4430076, 4451705, 4470788, 4474481, 4532359, 4540137, 4562763, 4567630, 4585083, 4585786, 4597507, 4597706, 4613290, 4619794, 4627901, 4651580, 4689918, 4692720, 4694319, 4694367, 4714015, 4720869, 4729169, 4739211, 4772184, 4784138, 4788021, 4790660, 4792801, 4817658, 4817748, 4817749, 4824424, 4825474, 4825489, 4826687, 4836316, 4838241, 4839685, 4840024, 4847580, 4859641, 4864213, 4869383, 4871603, 5025256, 5026963, 5026964, 5026977, 5026997, 5028204, 5029039, 5029051, 5029060, 5029170, 5029190, 5029192, 5029194, 5029199, 5029203, 5029818, 5029855, 5029856, 5036411, 5043969, 5044533, 5045572, 5045598, 5046131, 5048886, 5052766, 5055933, 5058491, 5059476, 5059699, 5060273, 5060764, 5061383, 5063697, 5065109, 5065694, 5066872, 5067717, 5070691, 5070698, 5072578, 5074491, 5080100, 5080445, 5080450, 5080457, 5081345, 5089396, 5108192, 5108209, 5112558, 5122354, 5122708, 5240644, 5241898, 5241909, 5242445, 5243237, 5244865, 5245058, 5253097, 5258426, 5259143, 5263419, 5265506, 5269047, 5270474, 5272591, 5275533, 5279062, 5279067, 5282112, 5282113, 5287542, 5294541, 5299177, 5305641, 5306255, 5306265, 5306290, 5308151, 5308452, 5312062, 5312114, 5312129, 5313134, 5315213, 5317757, 5319698, 5320256, 5321006, 5321224, 5323923, 5325472, 5326613, 5326975, 5328653, 5328684, 5330019, 5330160, 5330167, 5330175, 5330200, 5334608, 5353979, 5355416, 5361220, 5361263, 5362399, 5362444, 5363094, 5363100, 5364333, 5366810, 5366873, 5370840, 5375299, 5375352, 5376567, 5387741, 5392262, 5392872, 5398765, 5399614, 5416006, 5416185, 5416190, 5416594, 5421028, 5421604, 5428138, 5428185, 5428572, 5444923, 5444998, 5451816, 5455880, 5455904, 5458247, 5459449, 5459995, 5462427, 5466755, 5471339, 5471371, 5471380, 5471452, 5487271, 5493463, 5500150, 5502377, 5522186, 5542190, 5550438, 5550446, 5608681, 5619915, 5623882, 5633550, 5633554, 5633602, 5633607, 5633611, 5633612, 5633627, 5633633, 5633635, 5633637, 5633644, 5633651, 5633654, 5633656, 5633660, 5634497, 5644725, 5644732, 5644734)
                ORDER BY project_id;
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                CALL apoc.periodic.iterate(
                "
                    MATCH (pr:Project {id: $project_id})-[:INCLUDES]->(:Product)<-[:PARTICIPATED_IN]-(lp:LabelParticipant)<-[gpToLp:REPRESENTS]-(gp:GlobalParticipant)
                    WHERE lp.subaccountId <> pr.subaccountId
                    RETURN pr, lp, gpToLp, gp
                ",
                "
                    CALL apoc.util.sleep(1)
                    MERGE (nlp:LabelParticipant:Orchard {normalizedName: lp.normalizedName, vendorId: lp.vendorId, subaccountId: pr.subaccountId})
                    ON CREATE SET
                        nlp.id = datetime.realtime().epochMillis,
                        nlp.uuid = apoc.create.uuid(),
                        nlp.createdAt = datetime(),
                        nlp.createdBy = 'database/KDH-156_vendor_to_d3_p1:8'
                    SET nlp += apoc.map.removeKeys(lp, ['id', 'uuid', 'vendorId', 'subaccountId', 'createdAt', 'createdBy']),
                        nlp.lastModifiedAt = datetime(),
                        nlp.lastModifiedBy = 'database/KDH-156_vendor_to_d3_p1:8'
                    WITH *
                    CALL apoc.merge.relationship(gp, type(gpToLp), null, gpToLp, nlp)
                    YIELD rel AS rel
                    RETURN nlp as labelParticipant
                ",
                {batchSize:1, iterateList:true, parallel:false, params: {project_id: toInteger(event.PROJECT_ID)}}
                )
                YIELD total, failedOperations, errorMessages, failedBatches, batch
                RETURN total, failedOperations, errorMessages, failedBatches, batch;
            ]]>
        </cypherquery>
    </changeset>
    <changeset id="KDH-156_vendor_to_d3_p1:9" author="ssavva" run-always="true">
        <precondition>
            <sqlquery>
                SELECT PROJECT_ID
                FROM orchard_app_reporting_v2.art_relations_prod_art_relations.project
                WHERE project_id in (2060451, 2342055, 2638957, 2684669, 2692191, 2802276, 3126018, 3352634, 3444746, 3456521, 3478722, 3704667, 3716455, 3735783, 3761341, 3765717, 3767347, 3770815, 3770838, 3777958, 3777999, 3782273, 3789966, 3790470, 3815184, 3832406, 3839103, 3868869, 3877746, 3892358, 3941889, 3941890, 3954812, 3966784, 3979638, 4000241, 4118273, 4120864, 4170541, 4180123, 4184908, 4189354, 4192264, 4193190, 4193500, 4193604, 4196568, 4201785, 4203535, 4206802, 4206820, 4210050, 4210786, 4223078, 4234055, 4252394, 4265086, 4285504, 4286016, 4289417, 4295449, 4306434, 4308288, 4308707, 4312254, 4335874, 4336456, 4352944, 4356242, 4373891, 4374542, 4385980, 4387123, 4413370, 4416681, 4430076, 4451705, 4470788, 4474481, 4532359, 4540137, 4562763, 4567630, 4585083, 4585786, 4597507, 4597706, 4613290, 4619794, 4627901, 4651580, 4689918, 4692720, 4694319, 4694367, 4714015, 4720869, 4729169, 4739211, 4772184, 4784138, 4788021, 4790660, 4792801, 4817658, 4817748, 4817749, 4824424, 4825474, 4825489, 4826687, 4836316, 4838241, 4839685, 4840024, 4847580, 4859641, 4864213, 4869383, 4871603, 5025256, 5026963, 5026964, 5026977, 5026997, 5028204, 5029039, 5029051, 5029060, 5029170, 5029190, 5029192, 5029194, 5029199, 5029203, 5029818, 5029855, 5029856, 5036411, 5043969, 5044533, 5045572, 5045598, 5046131, 5048886, 5052766, 5055933, 5058491, 5059476, 5059699, 5060273, 5060764, 5061383, 5063697, 5065109, 5065694, 5066872, 5067717, 5070691, 5070698, 5072578, 5074491, 5080100, 5080445, 5080450, 5080457, 5081345, 5089396, 5108192, 5108209, 5112558, 5122354, 5122708, 5240644, 5241898, 5241909, 5242445, 5243237, 5244865, 5245058, 5253097, 5258426, 5259143, 5263419, 5265506, 5269047, 5270474, 5272591, 5275533, 5279062, 5279067, 5282112, 5282113, 5287542, 5294541, 5299177, 5305641, 5306255, 5306265, 5306290, 5308151, 5308452, 5312062, 5312114, 5312129, 5313134, 5315213, 5317757, 5319698, 5320256, 5321006, 5321224, 5323923, 5325472, 5326613, 5326975, 5328653, 5328684, 5330019, 5330160, 5330167, 5330175, 5330200, 5334608, 5353979, 5355416, 5361220, 5361263, 5362399, 5362444, 5363094, 5363100, 5364333, 5366810, 5366873, 5370840, 5375299, 5375352, 5376567, 5387741, 5392262, 5392872, 5398765, 5399614, 5416006, 5416185, 5416190, 5416594, 5421028, 5421604, 5428138, 5428185, 5428572, 5444923, 5444998, 5451816, 5455880, 5455904, 5458247, 5459449, 5459995, 5462427, 5466755, 5471339, 5471371, 5471380, 5471452, 5487271, 5493463, 5500150, 5502377, 5522186, 5542190, 5550438, 5550446, 5608681, 5619915, 5623882, 5633550, 5633554, 5633602, 5633607, 5633611, 5633612, 5633627, 5633633, 5633635, 5633637, 5633644, 5633651, 5633654, 5633656, 5633660, 5634497, 5644725, 5644732, 5644734)
                ORDER BY project_id;
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                CALL apoc.periodic.iterate(
                "
                    MATCH (pr:Project {id: $project_id})-[:INCLUDES]->(p:Product)<-[lpToP:PARTICIPATED_IN]-(lp:LabelParticipant)
                    WHERE lp.subaccountId <> pr.subaccountId
                    RETURN pr, lp, lpToP, p
                ",
                "
                    CALL apoc.util.sleep(1)
                    MERGE (nlp:LabelParticipant:Orchard {normalizedName: lp.normalizedName, vendorId: lp.vendorId, subaccountId: pr.subaccountId})
                        ON CREATE SET
                            nlp.id = datetime.realtime().epochMillis,
                            nlp.uuid = apoc.create.uuid(),
                            nlp.createdAt = datetime(),
                            nlp.createdBy = 'database/KDH-156_vendor_to_d3_p1:9'
                        SET nlp += apoc.map.removeKeys(lp, ['id', 'uuid', 'vendorId', 'subaccountId', 'createdAt', 'createdBy']),
                            nlp.lastModifiedAt = datetime(),
                            nlp.lastModifiedBy = 'database/KDH-156_vendor_to_d3_p1:9'
                    WITH *
                    CALL apoc.merge.relationship(nlp, type(lpToP), {participated_as: lpToP.participated_as}, lpToP, p)
                    YIELD rel AS rel
                    RETURN nlp as labelParticipant
                ",
                {batchSize:1, iterateList:true, parallel:false, params: {project_id: toInteger(event.PROJECT_ID)}}
                )
                YIELD total, failedOperations, errorMessages, failedBatches, batch
                RETURN total, failedOperations, errorMessages, failedBatches, batch;
            ]]>
        </cypherquery>
    </changeset>
    <changeset id="KDH-156_vendor_to_d3_p1:10" author="ssavva" run-always="true">
        <precondition>
            <sqlquery>
                SELECT PROJECT_ID
                FROM orchard_app_reporting_v2.art_relations_prod_art_relations.project
                WHERE project_id in (2060451, 2342055, 2638957, 2684669, 2692191, 2802276, 3126018, 3352634, 3444746, 3456521, 3478722, 3704667, 3716455, 3735783, 3761341, 3765717, 3767347, 3770815, 3770838, 3777958, 3777999, 3782273, 3789966, 3790470, 3815184, 3832406, 3839103, 3868869, 3877746, 3892358, 3941889, 3941890, 3954812, 3966784, 3979638, 4000241, 4118273, 4120864, 4170541, 4180123, 4184908, 4189354, 4192264, 4193190, 4193500, 4193604, 4196568, 4201785, 4203535, 4206802, 4206820, 4210050, 4210786, 4223078, 4234055, 4252394, 4265086, 4285504, 4286016, 4289417, 4295449, 4306434, 4308288, 4308707, 4312254, 4335874, 4336456, 4352944, 4356242, 4373891, 4374542, 4385980, 4387123, 4413370, 4416681, 4430076, 4451705, 4470788, 4474481, 4532359, 4540137, 4562763, 4567630, 4585083, 4585786, 4597507, 4597706, 4613290, 4619794, 4627901, 4651580, 4689918, 4692720, 4694319, 4694367, 4714015, 4720869, 4729169, 4739211, 4772184, 4784138, 4788021, 4790660, 4792801, 4817658, 4817748, 4817749, 4824424, 4825474, 4825489, 4826687, 4836316, 4838241, 4839685, 4840024, 4847580, 4859641, 4864213, 4869383, 4871603, 5025256, 5026963, 5026964, 5026977, 5026997, 5028204, 5029039, 5029051, 5029060, 5029170, 5029190, 5029192, 5029194, 5029199, 5029203, 5029818, 5029855, 5029856, 5036411, 5043969, 5044533, 5045572, 5045598, 5046131, 5048886, 5052766, 5055933, 5058491, 5059476, 5059699, 5060273, 5060764, 5061383, 5063697, 5065109, 5065694, 5066872, 5067717, 5070691, 5070698, 5072578, 5074491, 5080100, 5080445, 5080450, 5080457, 5081345, 5089396, 5108192, 5108209, 5112558, 5122354, 5122708, 5240644, 5241898, 5241909, 5242445, 5243237, 5244865, 5245058, 5253097, 5258426, 5259143, 5263419, 5265506, 5269047, 5270474, 5272591, 5275533, 5279062, 5279067, 5282112, 5282113, 5287542, 5294541, 5299177, 5305641, 5306255, 5306265, 5306290, 5308151, 5308452, 5312062, 5312114, 5312129, 5313134, 5315213, 5317757, 5319698, 5320256, 5321006, 5321224, 5323923, 5325472, 5326613, 5326975, 5328653, 5328684, 5330019, 5330160, 5330167, 5330175, 5330200, 5334608, 5353979, 5355416, 5361220, 5361263, 5362399, 5362444, 5363094, 5363100, 5364333, 5366810, 5366873, 5370840, 5375299, 5375352, 5376567, 5387741, 5392262, 5392872, 5398765, 5399614, 5416006, 5416185, 5416190, 5416594, 5421028, 5421604, 5428138, 5428185, 5428572, 5444923, 5444998, 5451816, 5455880, 5455904, 5458247, 5459449, 5459995, 5462427, 5466755, 5471339, 5471371, 5471380, 5471452, 5487271, 5493463, 5500150, 5502377, 5522186, 5542190, 5550438, 5550446, 5608681, 5619915, 5623882, 5633550, 5633554, 5633602, 5633607, 5633611, 5633612, 5633627, 5633633, 5633635, 5633637, 5633644, 5633651, 5633654, 5633656, 5633660, 5634497, 5644725, 5644732, 5644734)
                ORDER BY project_id;
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                CALL apoc.periodic.iterate(
                "
                    MATCH (pr:Project {id: $project_id})-[:INCLUDES]->(:Product)<-[:PARTICIPATED_IN]-(lp:LabelParticipant)-[cf:CREATED_FROM]->(ai:ArtistInfo)
                    WHERE lp.subaccountId <> pr.subaccountId
                    RETURN pr, lp, cf, ai
                ",
                "
                    CALL apoc.util.sleep(1)
                    MERGE (nlp:LabelParticipant:Orchard {normalizedName: lp.normalizedName, vendorId: lp.vendorId, subaccountId: pr.subaccountId})
                        ON CREATE SET
                            nlp.id = datetime.realtime().epochMillis,
                            nlp.uuid = apoc.create.uuid(),
                            nlp.createdAt = datetime(),
                            nlp.createdBy = 'database/KDH-156_vendor_to_d3_p1:10'
                        SET nlp += apoc.map.removeKeys(lp, ['id', 'uuid', 'vendorId', 'subaccountId', 'createdAt', 'createdBy']),
                            nlp.lastModifiedAt = datetime(),
                            nlp.lastModifiedBy = 'database/KDH-156_vendor_to_d3_p1:10'
                    WITH *
                    CALL apoc.merge.relationship(nlp, type(cf), null, cf, ai)
                    YIELD rel AS rel
                    RETURN nlp as labelParticipant
                ",
                {batchSize:1, iterateList:true, parallel:false, params: {project_id: toInteger(event.PROJECT_ID)}}
                )
                YIELD total, failedOperations, errorMessages, failedBatches, batch
                RETURN total, failedOperations, errorMessages, failedBatches, batch;
            ]]>
        </cypherquery>
    </changeset>
    <changeset id="KDH-156_vendor_to_d3_p1:11" author="ssavva" run-always="true">
        <precondition>
            <sqlquery>
                SELECT PROJECT_ID
                FROM orchard_app_reporting_v2.art_relations_prod_art_relations.project
                WHERE project_id in (2060451, 2342055, 2638957, 2684669, 2692191, 2802276, 3126018, 3352634, 3444746, 3456521, 3478722, 3704667, 3716455, 3735783, 3761341, 3765717, 3767347, 3770815, 3770838, 3777958, 3777999, 3782273, 3789966, 3790470, 3815184, 3832406, 3839103, 3868869, 3877746, 3892358, 3941889, 3941890, 3954812, 3966784, 3979638, 4000241, 4118273, 4120864, 4170541, 4180123, 4184908, 4189354, 4192264, 4193190, 4193500, 4193604, 4196568, 4201785, 4203535, 4206802, 4206820, 4210050, 4210786, 4223078, 4234055, 4252394, 4265086, 4285504, 4286016, 4289417, 4295449, 4306434, 4308288, 4308707, 4312254, 4335874, 4336456, 4352944, 4356242, 4373891, 4374542, 4385980, 4387123, 4413370, 4416681, 4430076, 4451705, 4470788, 4474481, 4532359, 4540137, 4562763, 4567630, 4585083, 4585786, 4597507, 4597706, 4613290, 4619794, 4627901, 4651580, 4689918, 4692720, 4694319, 4694367, 4714015, 4720869, 4729169, 4739211, 4772184, 4784138, 4788021, 4790660, 4792801, 4817658, 4817748, 4817749, 4824424, 4825474, 4825489, 4826687, 4836316, 4838241, 4839685, 4840024, 4847580, 4859641, 4864213, 4869383, 4871603, 5025256, 5026963, 5026964, 5026977, 5026997, 5028204, 5029039, 5029051, 5029060, 5029170, 5029190, 5029192, 5029194, 5029199, 5029203, 5029818, 5029855, 5029856, 5036411, 5043969, 5044533, 5045572, 5045598, 5046131, 5048886, 5052766, 5055933, 5058491, 5059476, 5059699, 5060273, 5060764, 5061383, 5063697, 5065109, 5065694, 5066872, 5067717, 5070691, 5070698, 5072578, 5074491, 5080100, 5080445, 5080450, 5080457, 5081345, 5089396, 5108192, 5108209, 5112558, 5122354, 5122708, 5240644, 5241898, 5241909, 5242445, 5243237, 5244865, 5245058, 5253097, 5258426, 5259143, 5263419, 5265506, 5269047, 5270474, 5272591, 5275533, 5279062, 5279067, 5282112, 5282113, 5287542, 5294541, 5299177, 5305641, 5306255, 5306265, 5306290, 5308151, 5308452, 5312062, 5312114, 5312129, 5313134, 5315213, 5317757, 5319698, 5320256, 5321006, 5321224, 5323923, 5325472, 5326613, 5326975, 5328653, 5328684, 5330019, 5330160, 5330167, 5330175, 5330200, 5334608, 5353979, 5355416, 5361220, 5361263, 5362399, 5362444, 5363094, 5363100, 5364333, 5366810, 5366873, 5370840, 5375299, 5375352, 5376567, 5387741, 5392262, 5392872, 5398765, 5399614, 5416006, 5416185, 5416190, 5416594, 5421028, 5421604, 5428138, 5428185, 5428572, 5444923, 5444998, 5451816, 5455880, 5455904, 5458247, 5459449, 5459995, 5462427, 5466755, 5471339, 5471371, 5471380, 5471452, 5487271, 5493463, 5500150, 5502377, 5522186, 5542190, 5550438, 5550446, 5608681, 5619915, 5623882, 5633550, 5633554, 5633602, 5633607, 5633611, 5633612, 5633627, 5633633, 5633635, 5633637, 5633644, 5633651, 5633654, 5633656, 5633660, 5634497, 5644725, 5644732, 5644734)
                ORDER BY project_id;
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                MATCH (pr:Project {id: toInteger(event.PROJECT_ID)})-[:INCLUDES]->(:Product)<-[:PARTICIPATED_IN]-(lp:LabelParticipant)-[cf:CREATED_FROM]->(:ArtistInfo)
                WHERE lp.subaccountId <> pr.subaccountId
                DELETE cf;
            ]]>
        </cypherquery>
    </changeset>
    <changeset id="KDH-156_vendor_to_d3_p1:12" author="ssavva" run-always="true">
        <precondition>
            <sqlquery>
                SELECT PROJECT_ID
                FROM orchard_app_reporting_v2.art_relations_prod_art_relations.project
                WHERE project_id in (2060451, 2342055, 2638957, 2684669, 2692191, 2802276, 3126018, 3352634, 3444746, 3456521, 3478722, 3704667, 3716455, 3735783, 3761341, 3765717, 3767347, 3770815, 3770838, 3777958, 3777999, 3782273, 3789966, 3790470, 3815184, 3832406, 3839103, 3868869, 3877746, 3892358, 3941889, 3941890, 3954812, 3966784, 3979638, 4000241, 4118273, 4120864, 4170541, 4180123, 4184908, 4189354, 4192264, 4193190, 4193500, 4193604, 4196568, 4201785, 4203535, 4206802, 4206820, 4210050, 4210786, 4223078, 4234055, 4252394, 4265086, 4285504, 4286016, 4289417, 4295449, 4306434, 4308288, 4308707, 4312254, 4335874, 4336456, 4352944, 4356242, 4373891, 4374542, 4385980, 4387123, 4413370, 4416681, 4430076, 4451705, 4470788, 4474481, 4532359, 4540137, 4562763, 4567630, 4585083, 4585786, 4597507, 4597706, 4613290, 4619794, 4627901, 4651580, 4689918, 4692720, 4694319, 4694367, 4714015, 4720869, 4729169, 4739211, 4772184, 4784138, 4788021, 4790660, 4792801, 4817658, 4817748, 4817749, 4824424, 4825474, 4825489, 4826687, 4836316, 4838241, 4839685, 4840024, 4847580, 4859641, 4864213, 4869383, 4871603, 5025256, 5026963, 5026964, 5026977, 5026997, 5028204, 5029039, 5029051, 5029060, 5029170, 5029190, 5029192, 5029194, 5029199, 5029203, 5029818, 5029855, 5029856, 5036411, 5043969, 5044533, 5045572, 5045598, 5046131, 5048886, 5052766, 5055933, 5058491, 5059476, 5059699, 5060273, 5060764, 5061383, 5063697, 5065109, 5065694, 5066872, 5067717, 5070691, 5070698, 5072578, 5074491, 5080100, 5080445, 5080450, 5080457, 5081345, 5089396, 5108192, 5108209, 5112558, 5122354, 5122708, 5240644, 5241898, 5241909, 5242445, 5243237, 5244865, 5245058, 5253097, 5258426, 5259143, 5263419, 5265506, 5269047, 5270474, 5272591, 5275533, 5279062, 5279067, 5282112, 5282113, 5287542, 5294541, 5299177, 5305641, 5306255, 5306265, 5306290, 5308151, 5308452, 5312062, 5312114, 5312129, 5313134, 5315213, 5317757, 5319698, 5320256, 5321006, 5321224, 5323923, 5325472, 5326613, 5326975, 5328653, 5328684, 5330019, 5330160, 5330167, 5330175, 5330200, 5334608, 5353979, 5355416, 5361220, 5361263, 5362399, 5362444, 5363094, 5363100, 5364333, 5366810, 5366873, 5370840, 5375299, 5375352, 5376567, 5387741, 5392262, 5392872, 5398765, 5399614, 5416006, 5416185, 5416190, 5416594, 5421028, 5421604, 5428138, 5428185, 5428572, 5444923, 5444998, 5451816, 5455880, 5455904, 5458247, 5459449, 5459995, 5462427, 5466755, 5471339, 5471371, 5471380, 5471452, 5487271, 5493463, 5500150, 5502377, 5522186, 5542190, 5550438, 5550446, 5608681, 5619915, 5623882, 5633550, 5633554, 5633602, 5633607, 5633611, 5633612, 5633627, 5633633, 5633635, 5633637, 5633644, 5633651, 5633654, 5633656, 5633660, 5634497, 5644725, 5644732, 5644734)
                ORDER BY project_id;
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                CALL apoc.periodic.iterate(
                "
                    MATCH (pr:Project {id: $project_id})-[:INCLUDES]->(p:Product)<-[:PARTICIPATED_IN]-(lp:LabelParticipant)
                    WHERE lp.subaccountId <> pr.subaccountId
                    MATCH (lp)-[lpToRa:CREATED_FROM]->(ra:ReleaseArtist {productId: p.id})
                    RETURN pr, lp, lpToRa, ra
                ",
                "
                    CALL apoc.util.sleep(1)
                    MERGE (nlp:LabelParticipant:Orchard {normalizedName: lp.normalizedName, vendorId: lp.vendorId, subaccountId: pr.subaccountId})
                        ON CREATE SET
                            nlp.id = datetime.realtime().epochMillis,
                            nlp.uuid = apoc.create.uuid(),
                            nlp.createdAt = datetime(),
                            nlp.createdBy = 'database/KDH-156_vendor_to_d3_p1:12'
                        SET nlp += apoc.map.removeKeys(lp, ['id', 'uuid', 'vendorId', 'subaccountId', 'createdAt', 'createdBy']),
                            nlp.lastModifiedAt = datetime(),
                            nlp.lastModifiedBy = 'database/KDH-156_vendor_to_d3_p1:12'
                    WITH *
                    CALL apoc.merge.relationship(nlp, type(lpToRa), null, lpToRa, ra)
                    YIELD rel AS rel
                    RETURN nlp as labelParticipant
                ",
                {batchSize:1, iterateList:true, parallel:false, params: {project_id: toInteger(event.PROJECT_ID)}}
                )
                YIELD total, failedOperations, errorMessages, failedBatches, batch
                RETURN total, failedOperations, errorMessages, failedBatches, batch;
            ]]>
        </cypherquery>
    </changeset>
    <changeset id="KDH-156_vendor_to_d3_p1:13" author="ssavva" run-always="true">
        <precondition>
            <sqlquery>
                SELECT PROJECT_ID
                FROM orchard_app_reporting_v2.art_relations_prod_art_relations.project
                WHERE project_id in (2060451, 2342055, 2638957, 2684669, 2692191, 2802276, 3126018, 3352634, 3444746, 3456521, 3478722, 3704667, 3716455, 3735783, 3761341, 3765717, 3767347, 3770815, 3770838, 3777958, 3777999, 3782273, 3789966, 3790470, 3815184, 3832406, 3839103, 3868869, 3877746, 3892358, 3941889, 3941890, 3954812, 3966784, 3979638, 4000241, 4118273, 4120864, 4170541, 4180123, 4184908, 4189354, 4192264, 4193190, 4193500, 4193604, 4196568, 4201785, 4203535, 4206802, 4206820, 4210050, 4210786, 4223078, 4234055, 4252394, 4265086, 4285504, 4286016, 4289417, 4295449, 4306434, 4308288, 4308707, 4312254, 4335874, 4336456, 4352944, 4356242, 4373891, 4374542, 4385980, 4387123, 4413370, 4416681, 4430076, 4451705, 4470788, 4474481, 4532359, 4540137, 4562763, 4567630, 4585083, 4585786, 4597507, 4597706, 4613290, 4619794, 4627901, 4651580, 4689918, 4692720, 4694319, 4694367, 4714015, 4720869, 4729169, 4739211, 4772184, 4784138, 4788021, 4790660, 4792801, 4817658, 4817748, 4817749, 4824424, 4825474, 4825489, 4826687, 4836316, 4838241, 4839685, 4840024, 4847580, 4859641, 4864213, 4869383, 4871603, 5025256, 5026963, 5026964, 5026977, 5026997, 5028204, 5029039, 5029051, 5029060, 5029170, 5029190, 5029192, 5029194, 5029199, 5029203, 5029818, 5029855, 5029856, 5036411, 5043969, 5044533, 5045572, 5045598, 5046131, 5048886, 5052766, 5055933, 5058491, 5059476, 5059699, 5060273, 5060764, 5061383, 5063697, 5065109, 5065694, 5066872, 5067717, 5070691, 5070698, 5072578, 5074491, 5080100, 5080445, 5080450, 5080457, 5081345, 5089396, 5108192, 5108209, 5112558, 5122354, 5122708, 5240644, 5241898, 5241909, 5242445, 5243237, 5244865, 5245058, 5253097, 5258426, 5259143, 5263419, 5265506, 5269047, 5270474, 5272591, 5275533, 5279062, 5279067, 5282112, 5282113, 5287542, 5294541, 5299177, 5305641, 5306255, 5306265, 5306290, 5308151, 5308452, 5312062, 5312114, 5312129, 5313134, 5315213, 5317757, 5319698, 5320256, 5321006, 5321224, 5323923, 5325472, 5326613, 5326975, 5328653, 5328684, 5330019, 5330160, 5330167, 5330175, 5330200, 5334608, 5353979, 5355416, 5361220, 5361263, 5362399, 5362444, 5363094, 5363100, 5364333, 5366810, 5366873, 5370840, 5375299, 5375352, 5376567, 5387741, 5392262, 5392872, 5398765, 5399614, 5416006, 5416185, 5416190, 5416594, 5421028, 5421604, 5428138, 5428185, 5428572, 5444923, 5444998, 5451816, 5455880, 5455904, 5458247, 5459449, 5459995, 5462427, 5466755, 5471339, 5471371, 5471380, 5471452, 5487271, 5493463, 5500150, 5502377, 5522186, 5542190, 5550438, 5550446, 5608681, 5619915, 5623882, 5633550, 5633554, 5633602, 5633607, 5633611, 5633612, 5633627, 5633633, 5633635, 5633637, 5633644, 5633651, 5633654, 5633656, 5633660, 5634497, 5644725, 5644732, 5644734)
                ORDER BY project_id;
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                MATCH (pr:Project {id: toInteger(event.PROJECT_ID)})-[:INCLUDES]->(p:Product)<-[lpToP:PARTICIPATED_IN]-(lp:LabelParticipant)
                WHERE lp.subaccountId <> pr.subaccountId
                OPTIONAL MATCH (lp)-[lpToRa:CREATED_FROM]->(:ReleaseArtist {productId: p.id})
                DELETE lpToP, lpToRa;
            ]]>
        </cypherquery>
    </changeset>
    <changeset id="KDH-156_vendor_to_d3_p1:14" author="ssavva" run-always="true">
        <precondition>
            <sqlquery>
                SELECT PROJECT_ID
                FROM orchard_app_reporting_v2.art_relations_prod_art_relations.project
                WHERE project_id in (2060451, 2342055, 2638957, 2684669, 2692191, 2802276, 3126018, 3352634, 3444746, 3456521, 3478722, 3704667, 3716455, 3735783, 3761341, 3765717, 3767347, 3770815, 3770838, 3777958, 3777999, 3782273, 3789966, 3790470, 3815184, 3832406, 3839103, 3868869, 3877746, 3892358, 3941889, 3941890, 3954812, 3966784, 3979638, 4000241, 4118273, 4120864, 4170541, 4180123, 4184908, 4189354, 4192264, 4193190, 4193500, 4193604, 4196568, 4201785, 4203535, 4206802, 4206820, 4210050, 4210786, 4223078, 4234055, 4252394, 4265086, 4285504, 4286016, 4289417, 4295449, 4306434, 4308288, 4308707, 4312254, 4335874, 4336456, 4352944, 4356242, 4373891, 4374542, 4385980, 4387123, 4413370, 4416681, 4430076, 4451705, 4470788, 4474481, 4532359, 4540137, 4562763, 4567630, 4585083, 4585786, 4597507, 4597706, 4613290, 4619794, 4627901, 4651580, 4689918, 4692720, 4694319, 4694367, 4714015, 4720869, 4729169, 4739211, 4772184, 4784138, 4788021, 4790660, 4792801, 4817658, 4817748, 4817749, 4824424, 4825474, 4825489, 4826687, 4836316, 4838241, 4839685, 4840024, 4847580, 4859641, 4864213, 4869383, 4871603, 5025256, 5026963, 5026964, 5026977, 5026997, 5028204, 5029039, 5029051, 5029060, 5029170, 5029190, 5029192, 5029194, 5029199, 5029203, 5029818, 5029855, 5029856, 5036411, 5043969, 5044533, 5045572, 5045598, 5046131, 5048886, 5052766, 5055933, 5058491, 5059476, 5059699, 5060273, 5060764, 5061383, 5063697, 5065109, 5065694, 5066872, 5067717, 5070691, 5070698, 5072578, 5074491, 5080100, 5080445, 5080450, 5080457, 5081345, 5089396, 5108192, 5108209, 5112558, 5122354, 5122708, 5240644, 5241898, 5241909, 5242445, 5243237, 5244865, 5245058, 5253097, 5258426, 5259143, 5263419, 5265506, 5269047, 5270474, 5272591, 5275533, 5279062, 5279067, 5282112, 5282113, 5287542, 5294541, 5299177, 5305641, 5306255, 5306265, 5306290, 5308151, 5308452, 5312062, 5312114, 5312129, 5313134, 5315213, 5317757, 5319698, 5320256, 5321006, 5321224, 5323923, 5325472, 5326613, 5326975, 5328653, 5328684, 5330019, 5330160, 5330167, 5330175, 5330200, 5334608, 5353979, 5355416, 5361220, 5361263, 5362399, 5362444, 5363094, 5363100, 5364333, 5366810, 5366873, 5370840, 5375299, 5375352, 5376567, 5387741, 5392262, 5392872, 5398765, 5399614, 5416006, 5416185, 5416190, 5416594, 5421028, 5421604, 5428138, 5428185, 5428572, 5444923, 5444998, 5451816, 5455880, 5455904, 5458247, 5459449, 5459995, 5462427, 5466755, 5471339, 5471371, 5471380, 5471452, 5487271, 5493463, 5500150, 5502377, 5522186, 5542190, 5550438, 5550446, 5608681, 5619915, 5623882, 5633550, 5633554, 5633602, 5633607, 5633611, 5633612, 5633627, 5633633, 5633635, 5633637, 5633644, 5633651, 5633654, 5633656, 5633660, 5634497, 5644725, 5644732, 5644734)
                ORDER BY project_id;
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                CALL apoc.periodic.iterate(
                "
                    MATCH (pr:Project {id: $project_id})-[:CREATED_FOR_PARTICIPANT]->(lp:LabelParticipant)-[cf:CREATED_FROM]->(ai:ArtistInfo)
                    WHERE lp.subaccountId <> pr.subaccountId
                    RETURN pr, lp, cf, ai
                ",
                "
                    CALL apoc.util.sleep(1)
                    MERGE (nlp:LabelParticipant:Orchard {normalizedName: lp.normalizedName, vendorId: lp.vendorId, subaccountId: pr.subaccountId})
                        ON CREATE SET
                            nlp.id = datetime.realtime().epochMillis,
                            nlp.uuid = apoc.create.uuid(),
                            nlp.createdAt = datetime(),
                            nlp.createdBy = 'database/KDH-156_vendor_to_d3_p1:14'
                        SET nlp += apoc.map.removeKeys(lp, ['id', 'uuid', 'vendorId', 'subaccountId', 'createdAt', 'createdBy']),
                            nlp.lastModifiedAt = datetime(),
                            nlp.lastModifiedBy = 'database/KDH-156_vendor_to_d3_p1:14'
                    WITH *
                    CALL apoc.merge.relationship(nlp, type(cf), null, cf, ai)
                    YIELD rel AS rel
                    RETURN nlp as labelParticipant
                ",
                {batchSize:1, iterateList:true, parallel:false, params: {project_id: toInteger(event.PROJECT_ID)}}
                )
                YIELD total, failedOperations, errorMessages, failedBatches, batch
                RETURN total, failedOperations, errorMessages, failedBatches, batch;
            ]]>
        </cypherquery>
    </changeset>
    <changeset id="KDH-156_vendor_to_d3_p1:15" author="ssavva" run-always="true">
        <precondition>
            <sqlquery>
                SELECT PROJECT_ID
                FROM orchard_app_reporting_v2.art_relations_prod_art_relations.project
                WHERE project_id in (2060451, 2342055, 2638957, 2684669, 2692191, 2802276, 3126018, 3352634, 3444746, 3456521, 3478722, 3704667, 3716455, 3735783, 3761341, 3765717, 3767347, 3770815, 3770838, 3777958, 3777999, 3782273, 3789966, 3790470, 3815184, 3832406, 3839103, 3868869, 3877746, 3892358, 3941889, 3941890, 3954812, 3966784, 3979638, 4000241, 4118273, 4120864, 4170541, 4180123, 4184908, 4189354, 4192264, 4193190, 4193500, 4193604, 4196568, 4201785, 4203535, 4206802, 4206820, 4210050, 4210786, 4223078, 4234055, 4252394, 4265086, 4285504, 4286016, 4289417, 4295449, 4306434, 4308288, 4308707, 4312254, 4335874, 4336456, 4352944, 4356242, 4373891, 4374542, 4385980, 4387123, 4413370, 4416681, 4430076, 4451705, 4470788, 4474481, 4532359, 4540137, 4562763, 4567630, 4585083, 4585786, 4597507, 4597706, 4613290, 4619794, 4627901, 4651580, 4689918, 4692720, 4694319, 4694367, 4714015, 4720869, 4729169, 4739211, 4772184, 4784138, 4788021, 4790660, 4792801, 4817658, 4817748, 4817749, 4824424, 4825474, 4825489, 4826687, 4836316, 4838241, 4839685, 4840024, 4847580, 4859641, 4864213, 4869383, 4871603, 5025256, 5026963, 5026964, 5026977, 5026997, 5028204, 5029039, 5029051, 5029060, 5029170, 5029190, 5029192, 5029194, 5029199, 5029203, 5029818, 5029855, 5029856, 5036411, 5043969, 5044533, 5045572, 5045598, 5046131, 5048886, 5052766, 5055933, 5058491, 5059476, 5059699, 5060273, 5060764, 5061383, 5063697, 5065109, 5065694, 5066872, 5067717, 5070691, 5070698, 5072578, 5074491, 5080100, 5080445, 5080450, 5080457, 5081345, 5089396, 5108192, 5108209, 5112558, 5122354, 5122708, 5240644, 5241898, 5241909, 5242445, 5243237, 5244865, 5245058, 5253097, 5258426, 5259143, 5263419, 5265506, 5269047, 5270474, 5272591, 5275533, 5279062, 5279067, 5282112, 5282113, 5287542, 5294541, 5299177, 5305641, 5306255, 5306265, 5306290, 5308151, 5308452, 5312062, 5312114, 5312129, 5313134, 5315213, 5317757, 5319698, 5320256, 5321006, 5321224, 5323923, 5325472, 5326613, 5326975, 5328653, 5328684, 5330019, 5330160, 5330167, 5330175, 5330200, 5334608, 5353979, 5355416, 5361220, 5361263, 5362399, 5362444, 5363094, 5363100, 5364333, 5366810, 5366873, 5370840, 5375299, 5375352, 5376567, 5387741, 5392262, 5392872, 5398765, 5399614, 5416006, 5416185, 5416190, 5416594, 5421028, 5421604, 5428138, 5428185, 5428572, 5444923, 5444998, 5451816, 5455880, 5455904, 5458247, 5459449, 5459995, 5462427, 5466755, 5471339, 5471371, 5471380, 5471452, 5487271, 5493463, 5500150, 5502377, 5522186, 5542190, 5550438, 5550446, 5608681, 5619915, 5623882, 5633550, 5633554, 5633602, 5633607, 5633611, 5633612, 5633627, 5633633, 5633635, 5633637, 5633644, 5633651, 5633654, 5633656, 5633660, 5634497, 5644725, 5644732, 5644734)
                ORDER BY project_id;
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                MATCH (pr:Project {id: toInteger(event.PROJECT_ID)})-[:CREATED_FOR_PARTICIPANT]->(lp:LabelParticipant)-[cf:CREATED_FROM]->(:ArtistInfo)
                WHERE lp.subaccountId <> pr.subaccountId
                DELETE cf;
            ]]>
        </cypherquery>
    </changeset>
    <changeset id="KDH-156_vendor_to_d3_p1:16" author="ssavva" run-always="true">
        <precondition>
            <sqlquery>
                SELECT PROJECT_ID
                FROM orchard_app_reporting_v2.art_relations_prod_art_relations.project
                WHERE project_id in (2060451, 2342055, 2638957, 2684669, 2692191, 2802276, 3126018, 3352634, 3444746, 3456521, 3478722, 3704667, 3716455, 3735783, 3761341, 3765717, 3767347, 3770815, 3770838, 3777958, 3777999, 3782273, 3789966, 3790470, 3815184, 3832406, 3839103, 3868869, 3877746, 3892358, 3941889, 3941890, 3954812, 3966784, 3979638, 4000241, 4118273, 4120864, 4170541, 4180123, 4184908, 4189354, 4192264, 4193190, 4193500, 4193604, 4196568, 4201785, 4203535, 4206802, 4206820, 4210050, 4210786, 4223078, 4234055, 4252394, 4265086, 4285504, 4286016, 4289417, 4295449, 4306434, 4308288, 4308707, 4312254, 4335874, 4336456, 4352944, 4356242, 4373891, 4374542, 4385980, 4387123, 4413370, 4416681, 4430076, 4451705, 4470788, 4474481, 4532359, 4540137, 4562763, 4567630, 4585083, 4585786, 4597507, 4597706, 4613290, 4619794, 4627901, 4651580, 4689918, 4692720, 4694319, 4694367, 4714015, 4720869, 4729169, 4739211, 4772184, 4784138, 4788021, 4790660, 4792801, 4817658, 4817748, 4817749, 4824424, 4825474, 4825489, 4826687, 4836316, 4838241, 4839685, 4840024, 4847580, 4859641, 4864213, 4869383, 4871603, 5025256, 5026963, 5026964, 5026977, 5026997, 5028204, 5029039, 5029051, 5029060, 5029170, 5029190, 5029192, 5029194, 5029199, 5029203, 5029818, 5029855, 5029856, 5036411, 5043969, 5044533, 5045572, 5045598, 5046131, 5048886, 5052766, 5055933, 5058491, 5059476, 5059699, 5060273, 5060764, 5061383, 5063697, 5065109, 5065694, 5066872, 5067717, 5070691, 5070698, 5072578, 5074491, 5080100, 5080445, 5080450, 5080457, 5081345, 5089396, 5108192, 5108209, 5112558, 5122354, 5122708, 5240644, 5241898, 5241909, 5242445, 5243237, 5244865, 5245058, 5253097, 5258426, 5259143, 5263419, 5265506, 5269047, 5270474, 5272591, 5275533, 5279062, 5279067, 5282112, 5282113, 5287542, 5294541, 5299177, 5305641, 5306255, 5306265, 5306290, 5308151, 5308452, 5312062, 5312114, 5312129, 5313134, 5315213, 5317757, 5319698, 5320256, 5321006, 5321224, 5323923, 5325472, 5326613, 5326975, 5328653, 5328684, 5330019, 5330160, 5330167, 5330175, 5330200, 5334608, 5353979, 5355416, 5361220, 5361263, 5362399, 5362444, 5363094, 5363100, 5364333, 5366810, 5366873, 5370840, 5375299, 5375352, 5376567, 5387741, 5392262, 5392872, 5398765, 5399614, 5416006, 5416185, 5416190, 5416594, 5421028, 5421604, 5428138, 5428185, 5428572, 5444923, 5444998, 5451816, 5455880, 5455904, 5458247, 5459449, 5459995, 5462427, 5466755, 5471339, 5471371, 5471380, 5471452, 5487271, 5493463, 5500150, 5502377, 5522186, 5542190, 5550438, 5550446, 5608681, 5619915, 5623882, 5633550, 5633554, 5633602, 5633607, 5633611, 5633612, 5633627, 5633633, 5633635, 5633637, 5633644, 5633651, 5633654, 5633656, 5633660, 5634497, 5644725, 5644732, 5644734)
                ORDER BY project_id;
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                CALL apoc.periodic.iterate(
                "
                    MATCH (pr:Project {id: $project_id})-[lpToP:CREATED_FOR_PARTICIPANT]->(lp:LabelParticipant)
                    WHERE lp.subaccountId <> pr.subaccountId
                    RETURN pr, lp, lpToP
                ",
                "
                    CALL apoc.util.sleep(1)
                    MERGE (nlp:LabelParticipant:Orchard {normalizedName: lp.normalizedName, vendorId: lp.vendorId, subaccountId: pr.subaccountId})
                        ON CREATE SET
                            nlp.id = datetime.realtime().epochMillis,
                            nlp.uuid = apoc.create.uuid(),
                            nlp.createdAt = datetime(),
                            nlp.createdBy = 'database/KDH-156_vendor_to_d3_p1:16'
                        SET nlp += apoc.map.removeKeys(lp, ['id', 'uuid', 'vendorId', 'subaccountId', 'createdAt', 'createdBy']),
                            nlp.lastModifiedAt = datetime(),
                            nlp.lastModifiedBy = 'database/KDH-156_vendor_to_d3_p1:16'
                    WITH *
                    CALL apoc.merge.relationship(pr, type(lpToP), null, lpToP, nlp)
                    YIELD rel AS rel
                    RETURN nlp as labelParticipant
                ",
                {batchSize:1, iterateList:true, parallel:false, params: {project_id: toInteger(event.PROJECT_ID)}}
                )
                YIELD total, failedOperations, errorMessages, failedBatches, batch
                RETURN total, failedOperations, errorMessages, failedBatches, batch;
            ]]>
        </cypherquery>
    </changeset>
    <changeset id="KDH-156_vendor_to_d3_p1:17" author="ssavva" run-always="true">
        <precondition>
            <sqlquery>
                SELECT PROJECT_ID
                FROM orchard_app_reporting_v2.art_relations_prod_art_relations.project
                WHERE project_id in (2060451, 2342055, 2638957, 2684669, 2692191, 2802276, 3126018, 3352634, 3444746, 3456521, 3478722, 3704667, 3716455, 3735783, 3761341, 3765717, 3767347, 3770815, 3770838, 3777958, 3777999, 3782273, 3789966, 3790470, 3815184, 3832406, 3839103, 3868869, 3877746, 3892358, 3941889, 3941890, 3954812, 3966784, 3979638, 4000241, 4118273, 4120864, 4170541, 4180123, 4184908, 4189354, 4192264, 4193190, 4193500, 4193604, 4196568, 4201785, 4203535, 4206802, 4206820, 4210050, 4210786, 4223078, 4234055, 4252394, 4265086, 4285504, 4286016, 4289417, 4295449, 4306434, 4308288, 4308707, 4312254, 4335874, 4336456, 4352944, 4356242, 4373891, 4374542, 4385980, 4387123, 4413370, 4416681, 4430076, 4451705, 4470788, 4474481, 4532359, 4540137, 4562763, 4567630, 4585083, 4585786, 4597507, 4597706, 4613290, 4619794, 4627901, 4651580, 4689918, 4692720, 4694319, 4694367, 4714015, 4720869, 4729169, 4739211, 4772184, 4784138, 4788021, 4790660, 4792801, 4817658, 4817748, 4817749, 4824424, 4825474, 4825489, 4826687, 4836316, 4838241, 4839685, 4840024, 4847580, 4859641, 4864213, 4869383, 4871603, 5025256, 5026963, 5026964, 5026977, 5026997, 5028204, 5029039, 5029051, 5029060, 5029170, 5029190, 5029192, 5029194, 5029199, 5029203, 5029818, 5029855, 5029856, 5036411, 5043969, 5044533, 5045572, 5045598, 5046131, 5048886, 5052766, 5055933, 5058491, 5059476, 5059699, 5060273, 5060764, 5061383, 5063697, 5065109, 5065694, 5066872, 5067717, 5070691, 5070698, 5072578, 5074491, 5080100, 5080445, 5080450, 5080457, 5081345, 5089396, 5108192, 5108209, 5112558, 5122354, 5122708, 5240644, 5241898, 5241909, 5242445, 5243237, 5244865, 5245058, 5253097, 5258426, 5259143, 5263419, 5265506, 5269047, 5270474, 5272591, 5275533, 5279062, 5279067, 5282112, 5282113, 5287542, 5294541, 5299177, 5305641, 5306255, 5306265, 5306290, 5308151, 5308452, 5312062, 5312114, 5312129, 5313134, 5315213, 5317757, 5319698, 5320256, 5321006, 5321224, 5323923, 5325472, 5326613, 5326975, 5328653, 5328684, 5330019, 5330160, 5330167, 5330175, 5330200, 5334608, 5353979, 5355416, 5361220, 5361263, 5362399, 5362444, 5363094, 5363100, 5364333, 5366810, 5366873, 5370840, 5375299, 5375352, 5376567, 5387741, 5392262, 5392872, 5398765, 5399614, 5416006, 5416185, 5416190, 5416594, 5421028, 5421604, 5428138, 5428185, 5428572, 5444923, 5444998, 5451816, 5455880, 5455904, 5458247, 5459449, 5459995, 5462427, 5466755, 5471339, 5471371, 5471380, 5471452, 5487271, 5493463, 5500150, 5502377, 5522186, 5542190, 5550438, 5550446, 5608681, 5619915, 5623882, 5633550, 5633554, 5633602, 5633607, 5633611, 5633612, 5633627, 5633633, 5633635, 5633637, 5633644, 5633651, 5633654, 5633656, 5633660, 5634497, 5644725, 5644732, 5644734)
                ORDER BY project_id;
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                MATCH (pr:Project {id: toInteger(event.PROJECT_ID)})-[lpToP:CREATED_FOR_PARTICIPANT]->(lp:LabelParticipant)
                WHERE lp.subaccountId <> pr.subaccountId
                DELETE lpToP;
            ]]>
        </cypherquery>
    </changeset>
    <changeset id="KDH-156_vendor_to_d3_p1:18" author="ssavva" run-always="true">
        <precondition>
            <sqlquery>
                SELECT PROJECT_ID
                FROM orchard_app_reporting_v2.art_relations_prod_art_relations.project
                WHERE project_id in (2060451, 2342055, 2638957, 2684669, 2692191, 2802276, 3126018, 3352634, 3444746, 3456521, 3478722, 3704667, 3716455, 3735783, 3761341, 3765717, 3767347, 3770815, 3770838, 3777958, 3777999, 3782273, 3789966, 3790470, 3815184, 3832406, 3839103, 3868869, 3877746, 3892358, 3941889, 3941890, 3954812, 3966784, 3979638, 4000241, 4118273, 4120864, 4170541, 4180123, 4184908, 4189354, 4192264, 4193190, 4193500, 4193604, 4196568, 4201785, 4203535, 4206802, 4206820, 4210050, 4210786, 4223078, 4234055, 4252394, 4265086, 4285504, 4286016, 4289417, 4295449, 4306434, 4308288, 4308707, 4312254, 4335874, 4336456, 4352944, 4356242, 4373891, 4374542, 4385980, 4387123, 4413370, 4416681, 4430076, 4451705, 4470788, 4474481, 4532359, 4540137, 4562763, 4567630, 4585083, 4585786, 4597507, 4597706, 4613290, 4619794, 4627901, 4651580, 4689918, 4692720, 4694319, 4694367, 4714015, 4720869, 4729169, 4739211, 4772184, 4784138, 4788021, 4790660, 4792801, 4817658, 4817748, 4817749, 4824424, 4825474, 4825489, 4826687, 4836316, 4838241, 4839685, 4840024, 4847580, 4859641, 4864213, 4869383, 4871603, 5025256, 5026963, 5026964, 5026977, 5026997, 5028204, 5029039, 5029051, 5029060, 5029170, 5029190, 5029192, 5029194, 5029199, 5029203, 5029818, 5029855, 5029856, 5036411, 5043969, 5044533, 5045572, 5045598, 5046131, 5048886, 5052766, 5055933, 5058491, 5059476, 5059699, 5060273, 5060764, 5061383, 5063697, 5065109, 5065694, 5066872, 5067717, 5070691, 5070698, 5072578, 5074491, 5080100, 5080445, 5080450, 5080457, 5081345, 5089396, 5108192, 5108209, 5112558, 5122354, 5122708, 5240644, 5241898, 5241909, 5242445, 5243237, 5244865, 5245058, 5253097, 5258426, 5259143, 5263419, 5265506, 5269047, 5270474, 5272591, 5275533, 5279062, 5279067, 5282112, 5282113, 5287542, 5294541, 5299177, 5305641, 5306255, 5306265, 5306290, 5308151, 5308452, 5312062, 5312114, 5312129, 5313134, 5315213, 5317757, 5319698, 5320256, 5321006, 5321224, 5323923, 5325472, 5326613, 5326975, 5328653, 5328684, 5330019, 5330160, 5330167, 5330175, 5330200, 5334608, 5353979, 5355416, 5361220, 5361263, 5362399, 5362444, 5363094, 5363100, 5364333, 5366810, 5366873, 5370840, 5375299, 5375352, 5376567, 5387741, 5392262, 5392872, 5398765, 5399614, 5416006, 5416185, 5416190, 5416594, 5421028, 5421604, 5428138, 5428185, 5428572, 5444923, 5444998, 5451816, 5455880, 5455904, 5458247, 5459449, 5459995, 5462427, 5466755, 5471339, 5471371, 5471380, 5471452, 5487271, 5493463, 5500150, 5502377, 5522186, 5542190, 5550438, 5550446, 5608681, 5619915, 5623882, 5633550, 5633554, 5633602, 5633607, 5633611, 5633612, 5633627, 5633633, 5633635, 5633637, 5633644, 5633651, 5633654, 5633656, 5633660, 5634497, 5644725, 5644732, 5644734)
                ORDER BY project_id;
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                CALL apoc.periodic.iterate(
                "
                    MATCH (pr:Project {id: $project_id})-[:INCLUDES]->(:Product)-[:INCLUDES]->(:Track)-[:IS_PLACEMENT_OF]->(:LabelSoundRecording)<-[:ON_LABEL_SOUND_RECORDING]-(lsrp:LabelSoundRecordingParticipation)<-[hlsrp:HAS_LABEL_SOUND_RECORDING_PARTICIPATION]-(lp:LabelParticipant)
                    WHERE lp.subaccountId <> pr.subaccountId
                    RETURN pr, lp, hlsrp, lsrp
                ",
                "
                    CALL apoc.util.sleep(1)
                    MERGE (nlp:LabelParticipant:Orchard {normalizedName: lp.normalizedName, vendorId: lp.vendorId, subaccountId: pr.subaccountId})
                        ON CREATE SET
                            nlp.id = datetime.realtime().epochMillis,
                            nlp.uuid = apoc.create.uuid(),
                            nlp.createdAt = datetime(),
                            nlp.createdBy = 'database/KDH-156_vendor_to_d3_p1:18'
                        SET nlp += apoc.map.removeKeys(lp, ['id', 'uuid', 'vendorId', 'subaccountId', 'createdAt', 'createdBy']),
                            nlp.lastModifiedAt = datetime(),
                            nlp.lastModifiedBy = 'database/KDH-156_vendor_to_d3_p1:18'
                    WITH *
                    CALL apoc.merge.relationship(nlp, type(hlsrp), null, hlsrp, lsrp)
                    YIELD rel AS rel
                    RETURN nlp as labelParticipant
                ",
                {batchSize:1, iterateList:true, parallel:false, params: {project_id: toInteger(event.PROJECT_ID)}}
                )
                YIELD total, failedOperations, errorMessages, failedBatches, batch
                RETURN total, failedOperations, errorMessages, failedBatches, batch;
            ]]>
        </cypherquery>
    </changeset>
    <changeset id="KDH-156_vendor_to_d3_p1:19" author="ssavva" run-always="true">
        <precondition>
            <sqlquery>
                SELECT PROJECT_ID
                FROM orchard_app_reporting_v2.art_relations_prod_art_relations.project
                WHERE project_id in (2060451, 2342055, 2638957, 2684669, 2692191, 2802276, 3126018, 3352634, 3444746, 3456521, 3478722, 3704667, 3716455, 3735783, 3761341, 3765717, 3767347, 3770815, 3770838, 3777958, 3777999, 3782273, 3789966, 3790470, 3815184, 3832406, 3839103, 3868869, 3877746, 3892358, 3941889, 3941890, 3954812, 3966784, 3979638, 4000241, 4118273, 4120864, 4170541, 4180123, 4184908, 4189354, 4192264, 4193190, 4193500, 4193604, 4196568, 4201785, 4203535, 4206802, 4206820, 4210050, 4210786, 4223078, 4234055, 4252394, 4265086, 4285504, 4286016, 4289417, 4295449, 4306434, 4308288, 4308707, 4312254, 4335874, 4336456, 4352944, 4356242, 4373891, 4374542, 4385980, 4387123, 4413370, 4416681, 4430076, 4451705, 4470788, 4474481, 4532359, 4540137, 4562763, 4567630, 4585083, 4585786, 4597507, 4597706, 4613290, 4619794, 4627901, 4651580, 4689918, 4692720, 4694319, 4694367, 4714015, 4720869, 4729169, 4739211, 4772184, 4784138, 4788021, 4790660, 4792801, 4817658, 4817748, 4817749, 4824424, 4825474, 4825489, 4826687, 4836316, 4838241, 4839685, 4840024, 4847580, 4859641, 4864213, 4869383, 4871603, 5025256, 5026963, 5026964, 5026977, 5026997, 5028204, 5029039, 5029051, 5029060, 5029170, 5029190, 5029192, 5029194, 5029199, 5029203, 5029818, 5029855, 5029856, 5036411, 5043969, 5044533, 5045572, 5045598, 5046131, 5048886, 5052766, 5055933, 5058491, 5059476, 5059699, 5060273, 5060764, 5061383, 5063697, 5065109, 5065694, 5066872, 5067717, 5070691, 5070698, 5072578, 5074491, 5080100, 5080445, 5080450, 5080457, 5081345, 5089396, 5108192, 5108209, 5112558, 5122354, 5122708, 5240644, 5241898, 5241909, 5242445, 5243237, 5244865, 5245058, 5253097, 5258426, 5259143, 5263419, 5265506, 5269047, 5270474, 5272591, 5275533, 5279062, 5279067, 5282112, 5282113, 5287542, 5294541, 5299177, 5305641, 5306255, 5306265, 5306290, 5308151, 5308452, 5312062, 5312114, 5312129, 5313134, 5315213, 5317757, 5319698, 5320256, 5321006, 5321224, 5323923, 5325472, 5326613, 5326975, 5328653, 5328684, 5330019, 5330160, 5330167, 5330175, 5330200, 5334608, 5353979, 5355416, 5361220, 5361263, 5362399, 5362444, 5363094, 5363100, 5364333, 5366810, 5366873, 5370840, 5375299, 5375352, 5376567, 5387741, 5392262, 5392872, 5398765, 5399614, 5416006, 5416185, 5416190, 5416594, 5421028, 5421604, 5428138, 5428185, 5428572, 5444923, 5444998, 5451816, 5455880, 5455904, 5458247, 5459449, 5459995, 5462427, 5466755, 5471339, 5471371, 5471380, 5471452, 5487271, 5493463, 5500150, 5502377, 5522186, 5542190, 5550438, 5550446, 5608681, 5619915, 5623882, 5633550, 5633554, 5633602, 5633607, 5633611, 5633612, 5633627, 5633633, 5633635, 5633637, 5633644, 5633651, 5633654, 5633656, 5633660, 5634497, 5644725, 5644732, 5644734)
                ORDER BY project_id;
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                MATCH (pr:Project {id: toInteger(event.PROJECT_ID)})-[:INCLUDES]->(:Product)-[:INCLUDES]->(t:Track)-[lsrToT]->(lsr:LabelSoundRecording)<-[:ON_LABEL_SOUND_RECORDING]-(lsrp:LabelSoundRecordingParticipation)<-[hlsrp:HAS_LABEL_SOUND_RECORDING_PARTICIPATION]-(lp:LabelParticipant)
                WHERE lp.subaccountId <> pr.subaccountId
                DELETE hlsrp;
            ]]>
        </cypherquery>
    </changeset>
    <changeset id="KDH-156_vendor_to_d3_p1:20" author="ssavva" run-always="true">
        <precondition>
            <sqlquery>
                SELECT PROJECT_ID
                FROM orchard_app_reporting_v2.art_relations_prod_art_relations.project
                WHERE project_id in (2060451, 2342055, 2638957, 2684669, 2692191, 2802276, 3126018, 3352634, 3444746, 3456521, 3478722, 3704667, 3716455, 3735783, 3761341, 3765717, 3767347, 3770815, 3770838, 3777958, 3777999, 3782273, 3789966, 3790470, 3815184, 3832406, 3839103, 3868869, 3877746, 3892358, 3941889, 3941890, 3954812, 3966784, 3979638, 4000241, 4118273, 4120864, 4170541, 4180123, 4184908, 4189354, 4192264, 4193190, 4193500, 4193604, 4196568, 4201785, 4203535, 4206802, 4206820, 4210050, 4210786, 4223078, 4234055, 4252394, 4265086, 4285504, 4286016, 4289417, 4295449, 4306434, 4308288, 4308707, 4312254, 4335874, 4336456, 4352944, 4356242, 4373891, 4374542, 4385980, 4387123, 4413370, 4416681, 4430076, 4451705, 4470788, 4474481, 4532359, 4540137, 4562763, 4567630, 4585083, 4585786, 4597507, 4597706, 4613290, 4619794, 4627901, 4651580, 4689918, 4692720, 4694319, 4694367, 4714015, 4720869, 4729169, 4739211, 4772184, 4784138, 4788021, 4790660, 4792801, 4817658, 4817748, 4817749, 4824424, 4825474, 4825489, 4826687, 4836316, 4838241, 4839685, 4840024, 4847580, 4859641, 4864213, 4869383, 4871603, 5025256, 5026963, 5026964, 5026977, 5026997, 5028204, 5029039, 5029051, 5029060, 5029170, 5029190, 5029192, 5029194, 5029199, 5029203, 5029818, 5029855, 5029856, 5036411, 5043969, 5044533, 5045572, 5045598, 5046131, 5048886, 5052766, 5055933, 5058491, 5059476, 5059699, 5060273, 5060764, 5061383, 5063697, 5065109, 5065694, 5066872, 5067717, 5070691, 5070698, 5072578, 5074491, 5080100, 5080445, 5080450, 5080457, 5081345, 5089396, 5108192, 5108209, 5112558, 5122354, 5122708, 5240644, 5241898, 5241909, 5242445, 5243237, 5244865, 5245058, 5253097, 5258426, 5259143, 5263419, 5265506, 5269047, 5270474, 5272591, 5275533, 5279062, 5279067, 5282112, 5282113, 5287542, 5294541, 5299177, 5305641, 5306255, 5306265, 5306290, 5308151, 5308452, 5312062, 5312114, 5312129, 5313134, 5315213, 5317757, 5319698, 5320256, 5321006, 5321224, 5323923, 5325472, 5326613, 5326975, 5328653, 5328684, 5330019, 5330160, 5330167, 5330175, 5330200, 5334608, 5353979, 5355416, 5361220, 5361263, 5362399, 5362444, 5363094, 5363100, 5364333, 5366810, 5366873, 5370840, 5375299, 5375352, 5376567, 5387741, 5392262, 5392872, 5398765, 5399614, 5416006, 5416185, 5416190, 5416594, 5421028, 5421604, 5428138, 5428185, 5428572, 5444923, 5444998, 5451816, 5455880, 5455904, 5458247, 5459449, 5459995, 5462427, 5466755, 5471339, 5471371, 5471380, 5471452, 5487271, 5493463, 5500150, 5502377, 5522186, 5542190, 5550438, 5550446, 5608681, 5619915, 5623882, 5633550, 5633554, 5633602, 5633607, 5633611, 5633612, 5633627, 5633633, 5633635, 5633637, 5633644, 5633651, 5633654, 5633656, 5633660, 5634497, 5644725, 5644732, 5644734)
                ORDER BY project_id;
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                CALL apoc.periodic.iterate(
                "
                    MATCH (pr:Project {id: $project_id})-[:INCLUDES]->(:Product)-[:INCLUDES]->(t:Track)-[lsrToT]-(lsr:LabelSoundRecording)<-[olsr:ON_LABEL_SOUND_RECORDING]-(lsrp:LabelSoundRecordingParticipation)
                    WHERE lsr.subaccountId <> pr.subaccountId
                    RETURN pr, lsr, olsr, lsrp
                ",
                "
                    MERGE (nlsr:LabelSoundRecording:Orchard {isrc: lsr.isrc, vendorId: pr.vendorId, subaccountId: pr.subaccountId})
                        ON CREATE SET
                            nlsr.id = apoc.create.uuid(),
                            nlsr.createdAt = datetime(),
                            nlsr.createdBy = 'database/KDH-156_vendor_to_d3_p1:20'
                        SET nlsr += apoc.map.removeKeys(lsr, ['id', 'isrc', 'vendorId', 'subaccountId', 'createdAt', 'createdBy']),
                            nlsr.lastModifiedAt = datetime(),
                            nlsr.lastModifiedBy = 'database/KDH-156_vendor_to_d3_p1:20'
                    WITH *
                    CALL apoc.merge.relationship(lsrp, type(olsr), {}, olsr, nlsr)
                    YIELD rel
                    RETURN nlsr as labelSoundRecording
                ",
                {batchSize:1, iterateList:true, parallel:false, params: {project_id: toInteger(event.PROJECT_ID)}}
                )
                YIELD total, failedOperations, errorMessages, failedBatches, batch
                RETURN total, failedOperations, errorMessages, failedBatches, batch;
            ]]>
        </cypherquery>
    </changeset>
    <changeset id="KDH-156_vendor_to_d3_p1:21" author="ssavva" run-always="true">
        <precondition>
            <sqlquery>
                SELECT PROJECT_ID
                FROM orchard_app_reporting_v2.art_relations_prod_art_relations.project
                WHERE project_id in (2060451, 2342055, 2638957, 2684669, 2692191, 2802276, 3126018, 3352634, 3444746, 3456521, 3478722, 3704667, 3716455, 3735783, 3761341, 3765717, 3767347, 3770815, 3770838, 3777958, 3777999, 3782273, 3789966, 3790470, 3815184, 3832406, 3839103, 3868869, 3877746, 3892358, 3941889, 3941890, 3954812, 3966784, 3979638, 4000241, 4118273, 4120864, 4170541, 4180123, 4184908, 4189354, 4192264, 4193190, 4193500, 4193604, 4196568, 4201785, 4203535, 4206802, 4206820, 4210050, 4210786, 4223078, 4234055, 4252394, 4265086, 4285504, 4286016, 4289417, 4295449, 4306434, 4308288, 4308707, 4312254, 4335874, 4336456, 4352944, 4356242, 4373891, 4374542, 4385980, 4387123, 4413370, 4416681, 4430076, 4451705, 4470788, 4474481, 4532359, 4540137, 4562763, 4567630, 4585083, 4585786, 4597507, 4597706, 4613290, 4619794, 4627901, 4651580, 4689918, 4692720, 4694319, 4694367, 4714015, 4720869, 4729169, 4739211, 4772184, 4784138, 4788021, 4790660, 4792801, 4817658, 4817748, 4817749, 4824424, 4825474, 4825489, 4826687, 4836316, 4838241, 4839685, 4840024, 4847580, 4859641, 4864213, 4869383, 4871603, 5025256, 5026963, 5026964, 5026977, 5026997, 5028204, 5029039, 5029051, 5029060, 5029170, 5029190, 5029192, 5029194, 5029199, 5029203, 5029818, 5029855, 5029856, 5036411, 5043969, 5044533, 5045572, 5045598, 5046131, 5048886, 5052766, 5055933, 5058491, 5059476, 5059699, 5060273, 5060764, 5061383, 5063697, 5065109, 5065694, 5066872, 5067717, 5070691, 5070698, 5072578, 5074491, 5080100, 5080445, 5080450, 5080457, 5081345, 5089396, 5108192, 5108209, 5112558, 5122354, 5122708, 5240644, 5241898, 5241909, 5242445, 5243237, 5244865, 5245058, 5253097, 5258426, 5259143, 5263419, 5265506, 5269047, 5270474, 5272591, 5275533, 5279062, 5279067, 5282112, 5282113, 5287542, 5294541, 5299177, 5305641, 5306255, 5306265, 5306290, 5308151, 5308452, 5312062, 5312114, 5312129, 5313134, 5315213, 5317757, 5319698, 5320256, 5321006, 5321224, 5323923, 5325472, 5326613, 5326975, 5328653, 5328684, 5330019, 5330160, 5330167, 5330175, 5330200, 5334608, 5353979, 5355416, 5361220, 5361263, 5362399, 5362444, 5363094, 5363100, 5364333, 5366810, 5366873, 5370840, 5375299, 5375352, 5376567, 5387741, 5392262, 5392872, 5398765, 5399614, 5416006, 5416185, 5416190, 5416594, 5421028, 5421604, 5428138, 5428185, 5428572, 5444923, 5444998, 5451816, 5455880, 5455904, 5458247, 5459449, 5459995, 5462427, 5466755, 5471339, 5471371, 5471380, 5471452, 5487271, 5493463, 5500150, 5502377, 5522186, 5542190, 5550438, 5550446, 5608681, 5619915, 5623882, 5633550, 5633554, 5633602, 5633607, 5633611, 5633612, 5633627, 5633633, 5633635, 5633637, 5633644, 5633651, 5633654, 5633656, 5633660, 5634497, 5644725, 5644732, 5644734)
                ORDER BY project_id;
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                MATCH (pr:Project {id: toInteger(event.PROJECT_ID)})-[:INCLUDES]->(:Product)-[:INCLUDES]->(t:Track)-[lsrToT]-(lsr:LabelSoundRecording)<-[olsr:ON_LABEL_SOUND_RECORDING]-(lsrp:LabelSoundRecordingParticipation)
                WHERE lsr.subaccountId <> pr.subaccountId
                DELETE olsr;
            ]]>
        </cypherquery>
    </changeset>
    <changeset id="KDH-156_vendor_to_d3_p1:22" author="ssavva" run-always="true">
        <precondition>
            <sqlquery>
                SELECT PROJECT_ID
                FROM orchard_app_reporting_v2.art_relations_prod_art_relations.project
                WHERE project_id in (2060451, 2342055, 2638957, 2684669, 2692191, 2802276, 3126018, 3352634, 3444746, 3456521, 3478722, 3704667, 3716455, 3735783, 3761341, 3765717, 3767347, 3770815, 3770838, 3777958, 3777999, 3782273, 3789966, 3790470, 3815184, 3832406, 3839103, 3868869, 3877746, 3892358, 3941889, 3941890, 3954812, 3966784, 3979638, 4000241, 4118273, 4120864, 4170541, 4180123, 4184908, 4189354, 4192264, 4193190, 4193500, 4193604, 4196568, 4201785, 4203535, 4206802, 4206820, 4210050, 4210786, 4223078, 4234055, 4252394, 4265086, 4285504, 4286016, 4289417, 4295449, 4306434, 4308288, 4308707, 4312254, 4335874, 4336456, 4352944, 4356242, 4373891, 4374542, 4385980, 4387123, 4413370, 4416681, 4430076, 4451705, 4470788, 4474481, 4532359, 4540137, 4562763, 4567630, 4585083, 4585786, 4597507, 4597706, 4613290, 4619794, 4627901, 4651580, 4689918, 4692720, 4694319, 4694367, 4714015, 4720869, 4729169, 4739211, 4772184, 4784138, 4788021, 4790660, 4792801, 4817658, 4817748, 4817749, 4824424, 4825474, 4825489, 4826687, 4836316, 4838241, 4839685, 4840024, 4847580, 4859641, 4864213, 4869383, 4871603, 5025256, 5026963, 5026964, 5026977, 5026997, 5028204, 5029039, 5029051, 5029060, 5029170, 5029190, 5029192, 5029194, 5029199, 5029203, 5029818, 5029855, 5029856, 5036411, 5043969, 5044533, 5045572, 5045598, 5046131, 5048886, 5052766, 5055933, 5058491, 5059476, 5059699, 5060273, 5060764, 5061383, 5063697, 5065109, 5065694, 5066872, 5067717, 5070691, 5070698, 5072578, 5074491, 5080100, 5080445, 5080450, 5080457, 5081345, 5089396, 5108192, 5108209, 5112558, 5122354, 5122708, 5240644, 5241898, 5241909, 5242445, 5243237, 5244865, 5245058, 5253097, 5258426, 5259143, 5263419, 5265506, 5269047, 5270474, 5272591, 5275533, 5279062, 5279067, 5282112, 5282113, 5287542, 5294541, 5299177, 5305641, 5306255, 5306265, 5306290, 5308151, 5308452, 5312062, 5312114, 5312129, 5313134, 5315213, 5317757, 5319698, 5320256, 5321006, 5321224, 5323923, 5325472, 5326613, 5326975, 5328653, 5328684, 5330019, 5330160, 5330167, 5330175, 5330200, 5334608, 5353979, 5355416, 5361220, 5361263, 5362399, 5362444, 5363094, 5363100, 5364333, 5366810, 5366873, 5370840, 5375299, 5375352, 5376567, 5387741, 5392262, 5392872, 5398765, 5399614, 5416006, 5416185, 5416190, 5416594, 5421028, 5421604, 5428138, 5428185, 5428572, 5444923, 5444998, 5451816, 5455880, 5455904, 5458247, 5459449, 5459995, 5462427, 5466755, 5471339, 5471371, 5471380, 5471452, 5487271, 5493463, 5500150, 5502377, 5522186, 5542190, 5550438, 5550446, 5608681, 5619915, 5623882, 5633550, 5633554, 5633602, 5633607, 5633611, 5633612, 5633627, 5633633, 5633635, 5633637, 5633644, 5633651, 5633654, 5633656, 5633660, 5634497, 5644725, 5644732, 5644734)
                ORDER BY project_id;
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                CALL apoc.periodic.iterate(
                "
                    MATCH (pr:Project {id: $project_id})-[:INCLUDES]->(:Product)-[:INCLUDES]->(:Track)-[:IS_PLACEMENT_OF]->(lsr:LabelSoundRecording)<-[lsrToGsr:REPRESENTS]-(gsr:GlobalSoundRecording)
                    WHERE lsr.subaccountId <> pr.subaccountId
                    RETURN pr, lsr, lsrToGsr, gsr
                ",
                "
                    MERGE (nlsr:LabelSoundRecording:Orchard {isrc: lsr.isrc, vendorId: pr.vendorId, subaccountId: pr.subaccountId})
                        ON CREATE SET
                            nlsr.id = apoc.create.uuid(),
                            nlsr.createdAt = datetime(),
                            nlsr.createdBy = 'database/KDH-156_vendor_to_d3_p1:22'
                        SET nlsr += apoc.map.removeKeys(lsr, ['id', 'isrc', 'vendorId', 'subaccountId', 'createdAt', 'createdBy']),
                            nlsr.lastModifiedAt = datetime(),
                            nlsr.lastModifiedBy = 'database/KDH-156_vendor_to_d3_p1:22'
                    WITH *
                    CALL apoc.merge.relationship(gsr, type(lsrToGsr), null, lsrToGsr, nlsr)
                    YIELD rel
                    RETURN true
                ",
                {batchSize:1, iterateList:true, parallel:false, params: {project_id: toInteger(event.PROJECT_ID)}}
                )
                YIELD total, failedOperations, errorMessages, failedBatches, batch
                RETURN total, failedOperations, errorMessages, failedBatches, batch;
            ]]>
        </cypherquery>
    </changeset>
    <changeset id="KDH-156_vendor_to_d3_p1:23" author="ssavva" run-always="true">
        <precondition>
            <sqlquery>
                SELECT PROJECT_ID
                FROM orchard_app_reporting_v2.art_relations_prod_art_relations.project
                WHERE project_id in (2060451, 2342055, 2638957, 2684669, 2692191, 2802276, 3126018, 3352634, 3444746, 3456521, 3478722, 3704667, 3716455, 3735783, 3761341, 3765717, 3767347, 3770815, 3770838, 3777958, 3777999, 3782273, 3789966, 3790470, 3815184, 3832406, 3839103, 3868869, 3877746, 3892358, 3941889, 3941890, 3954812, 3966784, 3979638, 4000241, 4118273, 4120864, 4170541, 4180123, 4184908, 4189354, 4192264, 4193190, 4193500, 4193604, 4196568, 4201785, 4203535, 4206802, 4206820, 4210050, 4210786, 4223078, 4234055, 4252394, 4265086, 4285504, 4286016, 4289417, 4295449, 4306434, 4308288, 4308707, 4312254, 4335874, 4336456, 4352944, 4356242, 4373891, 4374542, 4385980, 4387123, 4413370, 4416681, 4430076, 4451705, 4470788, 4474481, 4532359, 4540137, 4562763, 4567630, 4585083, 4585786, 4597507, 4597706, 4613290, 4619794, 4627901, 4651580, 4689918, 4692720, 4694319, 4694367, 4714015, 4720869, 4729169, 4739211, 4772184, 4784138, 4788021, 4790660, 4792801, 4817658, 4817748, 4817749, 4824424, 4825474, 4825489, 4826687, 4836316, 4838241, 4839685, 4840024, 4847580, 4859641, 4864213, 4869383, 4871603, 5025256, 5026963, 5026964, 5026977, 5026997, 5028204, 5029039, 5029051, 5029060, 5029170, 5029190, 5029192, 5029194, 5029199, 5029203, 5029818, 5029855, 5029856, 5036411, 5043969, 5044533, 5045572, 5045598, 5046131, 5048886, 5052766, 5055933, 5058491, 5059476, 5059699, 5060273, 5060764, 5061383, 5063697, 5065109, 5065694, 5066872, 5067717, 5070691, 5070698, 5072578, 5074491, 5080100, 5080445, 5080450, 5080457, 5081345, 5089396, 5108192, 5108209, 5112558, 5122354, 5122708, 5240644, 5241898, 5241909, 5242445, 5243237, 5244865, 5245058, 5253097, 5258426, 5259143, 5263419, 5265506, 5269047, 5270474, 5272591, 5275533, 5279062, 5279067, 5282112, 5282113, 5287542, 5294541, 5299177, 5305641, 5306255, 5306265, 5306290, 5308151, 5308452, 5312062, 5312114, 5312129, 5313134, 5315213, 5317757, 5319698, 5320256, 5321006, 5321224, 5323923, 5325472, 5326613, 5326975, 5328653, 5328684, 5330019, 5330160, 5330167, 5330175, 5330200, 5334608, 5353979, 5355416, 5361220, 5361263, 5362399, 5362444, 5363094, 5363100, 5364333, 5366810, 5366873, 5370840, 5375299, 5375352, 5376567, 5387741, 5392262, 5392872, 5398765, 5399614, 5416006, 5416185, 5416190, 5416594, 5421028, 5421604, 5428138, 5428185, 5428572, 5444923, 5444998, 5451816, 5455880, 5455904, 5458247, 5459449, 5459995, 5462427, 5466755, 5471339, 5471371, 5471380, 5471452, 5487271, 5493463, 5500150, 5502377, 5522186, 5542190, 5550438, 5550446, 5608681, 5619915, 5623882, 5633550, 5633554, 5633602, 5633607, 5633611, 5633612, 5633627, 5633633, 5633635, 5633637, 5633644, 5633651, 5633654, 5633656, 5633660, 5634497, 5644725, 5644732, 5644734)
                ORDER BY project_id;
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                CALL apoc.periodic.iterate(
                "
                    MATCH (pr:Project {id: $project_id})-[:INCLUDES]->(:Product)-[:INCLUDES]->(t:Track)-[lsrToT:IS_PLACEMENT_OF]->(lsr:LabelSoundRecording)
                    WHERE lsr.subaccountId <> pr.subaccountId
                    RETURN pr, lsr, lsrToT, t
                ",
                "
                    MERGE (nlsr:LabelSoundRecording:Orchard {isrc: lsr.isrc, vendorId: pr.vendorId, subaccountId: pr.subaccountId})
                        ON CREATE SET
                            nlsr.id = apoc.create.uuid(),
                            nlsr.createdAt = datetime(),
                            nlsr.createdBy = 'database/KDH-156_vendor_to_d3_p1:23'
                        SET nlsr += apoc.map.removeKeys(lsr, ['id', 'isrc', 'vendorId', 'subaccountId', 'createdAt', 'createdBy']),
                            nlsr.lastModifiedAt = datetime(),
                            nlsr.lastModifiedBy = 'database/KDH-156_vendor_to_d3_p1:23'
                    WITH *
                    CALL apoc.merge.relationship(t, type(lsrToT), null, lsrToT, nlsr)
                    YIELD rel
                    RETURN nlsr as labelSoundRecording
                ",
                {batchSize:1, iterateList:true, parallel:false, params: {project_id: toInteger(event.PROJECT_ID)}}
                )
                YIELD total, failedOperations, errorMessages, failedBatches, batch
                RETURN total, failedOperations, errorMessages, failedBatches, batch;
            ]]>
        </cypherquery>
    </changeset>
    <changeset id="KDH-156_vendor_to_d3_p1:24" author="ssavva" run-always="true">
        <precondition>
            <sqlquery>
                SELECT PROJECT_ID
                FROM orchard_app_reporting_v2.art_relations_prod_art_relations.project
                WHERE project_id in (2060451, 2342055, 2638957, 2684669, 2692191, 2802276, 3126018, 3352634, 3444746, 3456521, 3478722, 3704667, 3716455, 3735783, 3761341, 3765717, 3767347, 3770815, 3770838, 3777958, 3777999, 3782273, 3789966, 3790470, 3815184, 3832406, 3839103, 3868869, 3877746, 3892358, 3941889, 3941890, 3954812, 3966784, 3979638, 4000241, 4118273, 4120864, 4170541, 4180123, 4184908, 4189354, 4192264, 4193190, 4193500, 4193604, 4196568, 4201785, 4203535, 4206802, 4206820, 4210050, 4210786, 4223078, 4234055, 4252394, 4265086, 4285504, 4286016, 4289417, 4295449, 4306434, 4308288, 4308707, 4312254, 4335874, 4336456, 4352944, 4356242, 4373891, 4374542, 4385980, 4387123, 4413370, 4416681, 4430076, 4451705, 4470788, 4474481, 4532359, 4540137, 4562763, 4567630, 4585083, 4585786, 4597507, 4597706, 4613290, 4619794, 4627901, 4651580, 4689918, 4692720, 4694319, 4694367, 4714015, 4720869, 4729169, 4739211, 4772184, 4784138, 4788021, 4790660, 4792801, 4817658, 4817748, 4817749, 4824424, 4825474, 4825489, 4826687, 4836316, 4838241, 4839685, 4840024, 4847580, 4859641, 4864213, 4869383, 4871603, 5025256, 5026963, 5026964, 5026977, 5026997, 5028204, 5029039, 5029051, 5029060, 5029170, 5029190, 5029192, 5029194, 5029199, 5029203, 5029818, 5029855, 5029856, 5036411, 5043969, 5044533, 5045572, 5045598, 5046131, 5048886, 5052766, 5055933, 5058491, 5059476, 5059699, 5060273, 5060764, 5061383, 5063697, 5065109, 5065694, 5066872, 5067717, 5070691, 5070698, 5072578, 5074491, 5080100, 5080445, 5080450, 5080457, 5081345, 5089396, 5108192, 5108209, 5112558, 5122354, 5122708, 5240644, 5241898, 5241909, 5242445, 5243237, 5244865, 5245058, 5253097, 5258426, 5259143, 5263419, 5265506, 5269047, 5270474, 5272591, 5275533, 5279062, 5279067, 5282112, 5282113, 5287542, 5294541, 5299177, 5305641, 5306255, 5306265, 5306290, 5308151, 5308452, 5312062, 5312114, 5312129, 5313134, 5315213, 5317757, 5319698, 5320256, 5321006, 5321224, 5323923, 5325472, 5326613, 5326975, 5328653, 5328684, 5330019, 5330160, 5330167, 5330175, 5330200, 5334608, 5353979, 5355416, 5361220, 5361263, 5362399, 5362444, 5363094, 5363100, 5364333, 5366810, 5366873, 5370840, 5375299, 5375352, 5376567, 5387741, 5392262, 5392872, 5398765, 5399614, 5416006, 5416185, 5416190, 5416594, 5421028, 5421604, 5428138, 5428185, 5428572, 5444923, 5444998, 5451816, 5455880, 5455904, 5458247, 5459449, 5459995, 5462427, 5466755, 5471339, 5471371, 5471380, 5471452, 5487271, 5493463, 5500150, 5502377, 5522186, 5542190, 5550438, 5550446, 5608681, 5619915, 5623882, 5633550, 5633554, 5633602, 5633607, 5633611, 5633612, 5633627, 5633633, 5633635, 5633637, 5633644, 5633651, 5633654, 5633656, 5633660, 5634497, 5644725, 5644732, 5644734)
                ORDER BY project_id;
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                MATCH (pr:Project {id: toInteger(event.PROJECT_ID)})-[:INCLUDES]->(:Product)-[:INCLUDES]->(:Track)-[lsrToT:IS_PLACEMENT_OF]->(lsr:LabelSoundRecording)
                WHERE lsr.subaccountId <> pr.subaccountId
                DELETE lsrToT;
            ]]>
        </cypherquery>
    </changeset>
    <changeset id="KDH-156_vendor_to_d3_p1:25" author="ssavva" run-always="true">
        <precondition>
            <sqlquery>
                SELECT 1;
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                MATCH (lp:LabelParticipant)<-[sahlp:HAS_LABEL_PARTICIPANT]-(sa:Subaccount)
                WHERE lp.vendorId in [15974, 18819, 19734, 21966, 21989, 24583, 24828, 25379, 25434, 26022, 26071, 26110, 26139, 26664, 28263, 29409, 32517, 32984, 33833, 33916, 35570, 35705, 66947, 70666, 71306, 73620] and lp.subaccountId <> sa.id
                DELETE sahlp;
            ]]>
        </cypherquery>
    </changeset>
    <changeset id="KDH-156_vendor_to_d3_p1:26" author="ssavva" run-always="true">
        <precondition>
            <sqlquery>
                SELECT 1;
            </sqlquery>
        </precondition>
        <cypherquery>
            <![CDATA[
                MATCH (lp:LabelParticipant)
                WHERE lp.vendorId in [15974, 18819, 19734, 21966, 21989, 24583, 24828, 25379, 25434, 26022, 26071, 26110, 26139, 26664, 28263, 29409, 32517, 32984, 33833, 33916, 35570, 35705, 66947, 70666, 71306, 73620] AND lp.subaccountId <> 0
                MATCH (v:Vendor)
                WHERE v.id = lp.vendorId
                MATCH (sa:Subaccount)
                WHERE sa.id = lp.subaccountId
                MERGE (v)-[vhlp:HAS_LABEL_PARTICIPANT]->(lp)
                    ON CREATE SET
                        vhlp.createdAt = datetime(),
                        vhlp.createdBy = 'database/KDH-156_vendor_to_d3_p1:26',
                        vhlp.lastModifiedAt = datetime(),
                        vhlp.lastModifiedBy = 'database/KDH-156_vendor_to_d3_p1:26'
                MERGE (sa)-[sahlp:HAS_LABEL_PARTICIPANT]->(lp)
                    ON CREATE SET
                        sahlp.createdAt = datetime(),
                        sahlp.createdBy = 'database/KDH-156_vendor_to_d3_p1:26',
                        sahlp.lastModifiedAt = datetime(),
                        sahlp.lastModifiedBy = 'database/KDH-156_vendor_to_d3_p1:26'
                RETURN true;
            ]]>
        </cypherquery>
    </changeset>
</changelog>
