Is there a SQL command to delete previous events?

Home Forums Calendar Products Events Calendar PRO Is there a SQL command to delete previous events?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1452546
    Mike
    Participant

    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!

    #1453617
    Patricia
    Member

    Hey 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

    #1473535
    Support Droid
    Keymaster

    Hey 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

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Is there a SQL command to delete previous events?’ is closed to new replies.