Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,13 @@ public void resetDatabase() {
}
} catch (Exception exception) {
LOG.error(
"Error resetting database: "
+ "make sure the configured Neo4j user is allowed to run 'CREATE OR REPLACE DATABASE', "
+ "'SHOW CONSTRAINTS', 'DROP CONSTRAINT', 'SHOW INDEXES' and 'DROP INDEXES'.\n"
+ "Alternatively, disable database reset by setting 'reset_db' to false in the job specification.",
"""
Failed to reset Neo4j database. The reset uses CREATE OR REPLACE DATABASE when
supported; otherwise, or if that fails, it deletes all nodes and relationships and
drops constraints/indexes. Check that the configured Neo4j user can run either CREATE
OR REPLACE DATABASE or the fallback operations: MATCH/DETACH DELETE, SHOW/DROP
CONSTRAINTS, and SHOW/DROP INDEXES. To skip reset, set 'reset_db' to false in the job
specification.""",
Comment thread
Abacn marked this conversation as resolved.
exception);
}
}
Expand Down Expand Up @@ -163,10 +166,12 @@ private void dropSchema(Neo4jCapabilities capabilities) {
for (var constraint : constraints) {
LOG.info("Dropping constraint {}", constraint);

runAutocommit(
String.format("DROP CONSTRAINT %s", CypherPatterns.sanitize(constraint)),
Map.of(),
databaseResetMetadata("drop-constraint"));
session
.run(
String.format("DROP CONSTRAINT %s", CypherPatterns.sanitize(constraint)),
Map.of(),
databaseResetMetadata("drop-constraint"))
.consume();
}

LOG.info("Dropping indexes");
Expand All @@ -180,10 +185,12 @@ private void dropSchema(Neo4jCapabilities capabilities) {
for (var index : indexes) {
LOG.info("Dropping index {}", index);

runAutocommit(
String.format("DROP INDEX %s", CypherPatterns.sanitize(index)),
Map.of(),
databaseResetMetadata("drop-index"));
session
.run(
String.format("DROP INDEX %s", CypherPatterns.sanitize(index)),
Map.of(),
databaseResetMetadata("drop-index"))
.consume();
}
}
}
Expand Down
Loading