Log page migration script

A migration script is needed to bring the of old page move events into conformity with the new scheme.

See. log_page will, if this change is merged, henceforward contain the of the page that is being moved, rather than the page_id of the created redirect. Also, will now have a redirpageid parameter. A script is needed to migrate the old logging entries, i.e. those lacking a redirpageid parameter, and change the log_page to the proper value. The script needs to be able to handle the following scenarios:

Logic
This procedure will be followed for each of the old rows in the logging table:


 * Look up the namespace and title in the logging table ( and ). Was that page subsequently moved or deleted?
 * If it was deleted, then get the log_page of that deletion event, and put that in log_page of the page move event. STOP, we're done.
 * If it was moved, then recursively follow the trail till you find where it ultimately ends up.


 * If the page wasn't subsequently moved or deleted, then get its current page_id, and put that in log_page of the page move event. STOP, we're done.

Scenarios
Are there any scenarios for which this logic wouldn't work? Are there any scenarios we want to test it against?