Skip to content

Instantly share code, notes, and snippets.

@naz
Created October 8, 2018 11:40
Show Gist options
  • Save naz/532a06a88ae4b8b78cd805414dd2473d to your computer and use it in GitHub Desktop.
Save naz/532a06a88ae4b8b78cd805414dd2473d to your computer and use it in GitHub Desktop.
Ghost post restoration script (MySQL version)
-- show available versions for a post
SELECT `mr`.`id` 'version id', `p`.`id` 'post id', `p`.`title`, `mr`.`mobiledoc`
FROM `posts` `p`
JOIN `mobiledoc_revisions` `mr`
ON `p`.`id` = `mr`.`post_id`
WHERE `p`.`id` = '$POST_ID' \G
-- restore specific versions of the post
UPDATE `posts` `p`
JOIN `mobiledoc_revisions` `mr`
ON `p`.`id` = `mr`.`post_id`
SET `p`.`mobiledoc` = `mr`.`mobiledoc`
WHERE `mr`.`id` = '$VERSION_ID';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment