Created
January 25, 2012 15:06
-
-
Save jgebhardt/1676679 to your computer and use it in GitHub Desktop.
hotfix to manually generate MODx resource URIs from the tree after updating
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN TRANSACTION; | |
WITH builder AS( | |
SELECT id , alias , parent, CAST('' AS VARCHAR(765)) [path], 0 [iter], parent [top], CAST('root' AS VARCHAR(300)) [hierarchy] | |
FROM dbo.modx_site_content parent | |
UNION ALL | |
SELECT child.id, child.alias, parent.parent, CAST(path AS VARCHAR(255)) + CAST('/' AS VARCHAR(255)) + CAST(child.alias AS VARCHAR(255)) [path], iter + 1 [iter], child.parent [top], CAST(hierarchy AS VARCHAR(100)) + CAST('/' AS VARCHAR(100)) + CAST(child.id AS VARCHAR(100)) [hierarchy] | |
FROM dbo.modx_site_content child | |
INNER JOIN builder parent ON child.parent= parent.id | |
) | |
UPDATE [content] | |
SET [content].uri = builder.[path] | |
FROM dbo.modx_site_content [content] | |
INNER JOIN builder ON [content].id = builder.id AND builder.parent = 0 | |
COMMIT TRANSACTION |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment