Skip to content

Instantly share code, notes, and snippets.

@demeritcowboy
Last active March 28, 2022 03:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save demeritcowboy/8ce328b9ca13eb735b00832266eaa5c8 to your computer and use it in GitHub Desktop.
Save demeritcowboy/8ce328b9ca13eb735b00832266eaa5c8 to your computer and use it in GitHub Desktop.
Recovering from 5.47.0-.2 using a pre-5.47 database backup

Skills/Prerequisites

  • Upgrading to 5.47.3 alone did not sufficiently fix your event times and there's too many to fix manually.
  • Most of the events you need to fix were made before you originally upgraded to 5.47.
  • Either MySQL command line or phpMyAdmin.
  • Access to a pre-5.47 database backup.

Steps

  1. Make a current database backup just in case.
  2. Restore the civicrm_event table from a pre-5.47 backup to a new temporary table called tmp_civicrm_event.
    • Do not replace the existing civicrm_event table.
  3. Run these SQL commands:
    UPDATE civicrm_event e INNER JOIN tmp_civicrm_event t ON t.id = e.id SET e.start_date = t.start_date;
    UPDATE civicrm_event e INNER JOIN tmp_civicrm_event t ON t.id = e.id SET e.end_date = t.end_date;
    UPDATE civicrm_event e INNER JOIN tmp_civicrm_event t ON t.id = e.id SET e.registration_start_date = t.registration_start_date;
    UPDATE civicrm_event e INNER JOIN tmp_civicrm_event t ON t.id = e.id SET e.registration_end_date = t.registration_end_date;
    
  4. Then the only ones you'll need to manually fix are:
    • New events you added since 5.47 (some may be fine, some will be off).
    • Events that pre-existed before 5.47 and have since been rescheduled in real life. E.g. In Feb you created an event for April 12th. Then you upgraded to 5.47. Then in real life the event was rescheduled to April 13th, so you edited the event. Then you did the restore. It will be back to April 12th so you need to edit it again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment