Skip to content

Instantly share code, notes, and snippets.

@ziadoz
Last active December 18, 2015 08:19
Show Gist options
  • Save ziadoz/5752625 to your computer and use it in GitHub Desktop.
Save ziadoz/5752625 to your computer and use it in GitHub Desktop.
Perch: Restore Records
-- Update record revision numbers for a region, so they display in Perch.
-- Replace :regionID and :revisionNum
UPDATE perch2_content_items pci
INNER JOIN
(
SELECT
itemID,
MAX(itemRev) AS itemRevMax
FROM perch2_content_items
WHERE regionID = :regionID
GROUP BY itemID
) AS max
ON pci.itemID = max.itemID AND pci.itemRev = max.itemRevMax
SET pci.itemRev = :revisionNum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment