Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-04-2020 10:16 AM
Not able to create multiple constraints through code.
I am creating some constraint statements for my neo4j DB through code, and I loop through all of them and create the respective cypher statements:
//loop through constraints
const statement = `CREATE CONSTRAINT ON (${name}:${type}) ASSERT ${name}.${parameter} IS UNIQUE`
runConstraint(driver, statement)
function runConstraint(driver, constraintStatement) {
var session = driver.session()
return session
.run(constraintStatement)
.then((result) => {
session.close()
console.log('result : ', result)
})
.catch((error) => {
session.close()
console.log('error : ', error)
})
}
The code should create all the constraints one by one, since I'm using a new session object for each call. Shouldn't each Session.close commit the transaction?
After the first constraint is created, I get:
error : Neo4jError: Database constraints have changed (txId=26) after this transaction (txId=1) started, which is not yet supported. Please retry your transaction to ensure all constraints are executed.
All the sessions of the conference are now available online