private void migrateDatabase() {
final GraphDatabaseService graphDb = getService(NodeService.class).getGraphDb();
final SecurityContext superUserContext = SecurityContext.getSuperUserInstance();
final NodeFactory nodeFactory = new NodeFactory(superUserContext);
final RelationshipFactory relFactory = new RelationshipFactory(superUserContext);
final App app = StructrApp.getInstance();
final StringProperty uuidProperty = new StringProperty("uuid");
final int txLimit = 2000;
boolean hasChanges = true;
int actualNodeCount = 0;
int actualRelCount = 0;
logger.log(Level.INFO, "Migration of ID properties from uuid to id requested.");
while (hasChanges) {
hasChanges = false;
try (final Tx tx = app.tx(false, false)) {
// iterate over all nodes,
final Iterator<Node> allNodes = GlobalGraphOperations.at(graphDb).getAllNodes().iterator();
while (allNodes.hasNext()) {
final Node node = allNodes.next();
// do migration of our own ID properties (and only our own!)
if (node.hasProperty("uuid") && node.getProperty("uuid") instanceof String && !node.hasProperty("id")) {
try {
final NodeInterface nodeInterface = nodeFactory.instantiate(node);
final String uuid = nodeInterface.getProperty(uuidProperty);
if (uuid != null) {
nodeInterface.setProperty(GraphObject.id, uuid);