diff --git a/db-migration-worker/migration/neo4j/comments.cql b/db-migration-worker/migration/neo4j/comments.cql index 16537b730..6709acbc8 100644 --- a/db-migration-worker/migration/neo4j/comments.cql +++ b/db-migration-worker/migration/neo4j/comments.cql @@ -1,12 +1,14 @@ -CALL apoc.load.json('file:/mongo-export/comments.json') YIELD value as comment -MERGE (c:Comment {id: comment._id["$oid"]}) +CALL apoc.load.json('file:/mongo-export/comments.json') YIELD value as json +MERGE (comment:Comment {id: json._id["$oid"]}) ON CREATE SET -c.content = comment.content, -c.contentExcerpt = comment.contentExcerpt, -c.deleted = comment.deleted, -c.disabled = false -WITH comment -MATCH (p:Post {id: comment.contributionId}), (u:User {id: comment.userId}) -MERGE (c)-[:COMMENTS]->(p) -MERGE (u)-[:WROTE]->(c) +comment.content = json.content, +comment.contentExcerpt = json.contentExcerpt, +comment.deleted = json.deleted, +comment.disabled = false +WITH comment, json, json.contributionId as postId +MATCH (post:Post {id: postId}) +WITH comment, post, json.userId as userId +MATCH (author:User {id: userId}) +MERGE (comment)-[:COMMENTS]->(post) +MERGE (author)-[:WROTE]->(comment) ;