Created
June 16, 2022 11:49
-
-
Save kinglozzer/9e6b51774e4777db2014c7c9efe25c89 to your computer and use it in GitHub Desktop.
Migrating elemental from a subclass of Page to Page
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
# Assumes the first non-zero ElementalAreaID in the versions table is the correct one to use | |
# (because they basically never change). Swap out table names as appropriate for your class. | |
# Don't forget to update Page_Live too! | |
UPDATE Page p | |
INNER JOIN | |
( | |
SELECT RecordID, ElementalAreaID | |
FROM CaseStudyPage_Versions | |
WHERE ElementalAreaID > 0 | |
GROUP BY RecordID, ElementalAreaID, Version | |
ORDER BY Version ASC | |
) c | |
ON p.ID = c.RecordID | |
SET p.ElementalAreaID = c.ElementalAreaID | |
WHERE c.RecordID IS NOT NULL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment