Tuesday, October 5, 2010

SQL to update pathes for modules with multisite drupal installation


Modules was setted up for one site from multisite drupal installation. So we have it installed in /sites/test.com/modules/ and that pathes we have in system table in DB. Now we need to see them on other site for example test.org so all pathes should be /sites/test.org/modules/.


UPDATE `system` t, (
SELECT REPLACE(filename, 'test.com', 'test.org') as test, name as name, type as type
FROM `system` WHERE `filename` LIKE '%test.com%') AS t2
SET t.filename = t2.test
WHERE t.name = t2.name AND t.type = t2.type