Batching schema operations

Hi!

I had lots of luck posting here last time so I thought I'd give it another shot. I'm trying to look into how to batch schema operations. I currently batch operations with apoc.periodic.iterate and then run apoc.cypher.doIt, as the iterator. This has worked great up until now but I'm looking to batch schema operations.

I started seeing the following error:

Error: org.neo4j.graphdb.QueryExecutionException: Schema operation 'create_constraint' on database 'neo4j' is not allowed for user '' with FULL overridden by TOKEN_WRITE overridden by TOKEN_WRITE.

After digging into it, it looks like apoc.periodic.iterate can only accept non-schema operations as the queries that it runs. I switched apoc.cypher.doIt to apoc.cypher.runSchema and it produces the same error.

I've tried a couple other things like using apoc.periodic.runMany and separating each schema operation statement with a semicolon but no luck there and running multiple schema operation statements in a single query without a procedure/function.

For reference, these are the types of queries that I wish to batch in one call to the neo4j DB:

CREATE CONSTRAINT IF NOT EXISTS FOR (model:modelName1) REQUIRE model.property IS UNIQUE
CREATE CONSTRAINT IF NOT EXISTS FOR (model:modelName2) REQUIRE model.property IS UNIQUE
CREATE CONSTRAINT IF NOT EXISTS FOR (model:modelName3) REQUIRE model.property IS UNIQUE
etc...

Any suggestions would be greatly appreciated!

I don't think there is any 'batching' possible, since each statement is executed separately (purpose of the semicolons to break up the statement).

Also,, how many create constraint statements do you have the would require batching if it was possible. Plus, it is one-time process.

Have you tried call apoc.cypher.runSchema for each constraint?

Yeah the thing is I've got hundreds of these operations at any given time, so it's not feasible to do a roundtrip to the DB for each statement. It's a fairly common occurrence. I've tried apoc.cypher.runSchema but again that only runs one schema operation so it doesn't give me much benefit from just running a single statement without that procedure.