Home › Forums › Calendar Products › Events Calendar PRO › Is there a SQL command to delete previous events?
- This topic has 3 replies, 2 voices, and was last updated 6 years, 2 months ago by Mike.
-
AuthorPosts
-
February 14, 2018 at 12:56 am #1452546MikeParticipant
I cloned our Live site to a shared hosting account to test out upgrading PHP. Unfortunately, our Live database is huge (60,000 orders, 8,500 events, etc.), and I am pretty sure that it is having a very negative effect on the loading speed of everything. I’d like to delete all of the expired events via SQL in PHPMYADMIN, using a query similar to this snippet for deleting Woocommerce Orders:
update wp_posts set post_status = 'trash' where post_type = 'shop_order';
The problem is that I only want to delete past events, as I would like to keep the upcoming events in the database for testing. Is there a way to use something like the previous code, but set for Tribe Events with an Event End Date less than or equal to Feb 1st?
Thank you!
February 14, 2018 at 3:50 pm #1453617PatriciaMemberHey Mike,
Thank you for reaching out to us!
You can use the following query to achieve what you want and move all events before a specific Event End Date to trash:
https://gist.github.com/nefeline/f9c21a69fbfcc77068797be72f4a233b
In your case you can replace line 11:
AND t2.meta_value <= DATE_SUB( CURDATE(), INTERVAL 2 MONTH )
with:
AND t2.meta_value <= Date('2018-02-01')
to move all events that finished before Feb 1st to trash.
To permanently delete your past events you can use the following query (and modify line 11 as well):
https://gist.github.com/nefeline/86e5a52401b22dc6ab6129ad869ce892
Please backup your database before running any of these queries.
I hope this helps! If you have any other questions at all please feel free to let me know and I’d be happy to help as best I can!
Cheers,
Patricia
March 8, 2018 at 8:35 am #1473535Support DroidKeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘Is there a SQL command to delete previous events?’ is closed to new replies.