samuelhauser
5/29/2019 - 1:43 PM

Move large Neos NodeTree to new Parent with MySQL

START TRANSACTION;
SET NAMES utf8 COLLATE utf8_unicode_ci;
alter database YOUR_DATABASE default character set utf8;
alter database YOUR_DATABASE default collate utf8_unicode_ci;

SET @whereLikePath = '%node-57fe3793425c0%';
SET @oldPath = '/sites/theme/node-57fe3793425c0';
SET @newPath = '/sites/theme/node-nm3vs6pu3hzod/node-57fe3793425c0';
SET @oldParentpath = '/sites/theme';
SET @newParentpath = '/sites/theme/node-nm3vs6pu3hzod';

UPDATE YOUR_DATABASE.neos_contentrepository_domain_model_nodedata n SET n.`path` = REPLACE(n.`path`, @oldPath, @newPath), n.parentpath = REPLACE(n.parentpath, @oldParentpath, @newParentpath), n.pathhash = MD5(n.`path`), n.parentpathhash = MD5(n.parentpath) WHERE n.`path` like @whereLikePath;
COMMIT;
START TRANSACTION;
SET NAMES utf8 COLLATE utf8_unicode_ci;
alter database YOUR_DATABASE default character set utf8;
alter database YOUR_DATABASE default collate utf8_unicode_ci;

SET @whereLikePath = '%node-q8ddaajoua2j3%';
SET @oldName = 'node-q8ddaajoua2j3';
SET @newName = 'node-5c1t64seyao71';

UPDATE YOUR_DATABASE.neos_contentrepository_domain_model_nodedata n SET n.`path` = REPLACE(n.`path`, @oldName, @newName), n.parentpath = REPLACE(n.parentpath, @oldName, @newName), n.pathhash = MD5(n.`path`), n.parentpathhash = MD5(n.parentpath) WHERE n.`path` like @whereLikePath;
COMMIT;