From d5afb6c7900a74eb162fc69eafadcb610ccebb24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Fri, 22 Nov 2019 19:31:19 +0100 Subject: [PATCH] Add old script again as template --- .../change_report_node_to_relationship.sh | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 neo4j/storeOldScriptsAsTemplates/change_report_node_to_relationship.sh diff --git a/neo4j/storeOldScriptsAsTemplates/change_report_node_to_relationship.sh b/neo4j/storeOldScriptsAsTemplates/change_report_node_to_relationship.sh new file mode 100644 index 000000000..8fb2ad4db --- /dev/null +++ b/neo4j/storeOldScriptsAsTemplates/change_report_node_to_relationship.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +ENV_FILE=$(dirname "$0")/.env +[[ -f "$ENV_FILE" ]] && source "$ENV_FILE" + +if [ -z "$NEO4J_USERNAME" ] || [ -z "$NEO4J_PASSWORD" ]; then + echo "Please set NEO4J_USERNAME and NEO4J_PASSWORD environment variables." + echo "Database manipulation is not possible without connecting to the database." + echo "E.g. you could \`cp .env.template .env\` unless you run the script in a docker container" +fi + +until echo 'RETURN "Connection successful" as info;' | cypher-shell +do + echo "Connecting to neo4j failed, trying again..." + sleep 1 +done + +echo " +MATCH (submitter:User)-[:REPORTED]->(report:Report)-[:REPORTED]->(resource) +DETACH DELETE report +CREATE (submitter)-[reported:REPORTED]->(resource) +SET reported.createdAt = toString(datetime()) +SET reported.reasonCategory = 'other' +SET reported.reasonDescription = '!!! Created automatically to ensure database consistency! Creation date is when the database manipulation happened.' +RETURN reported; +" | cypher-shell \ No newline at end of file