By Mist on Tuesday, 01 April 2014
Replies 5
Likes 0
Views 1.4K
Votes 0
Since EasySocial laks few options we may need i was thinking about opening a discussion here for grouping together all the useful queries we may use in some cases.
Note: These SQL queries should be run inside phpMyAdmin directly inside the targeted database. Use them at your own risk and ALWAYS backup your database before running a custom query

1. Delete all Easy Social user posts for a specific user id

delete from jos_social_stream where actor_id="REPLACE_WITH_USER_ID" and actor_type="user"
delete from jos_social_stream_item where actor_id="REPLACE_WITH_USER_ID" and actor_type="user"

* replace "jos_" with your own table prefix.

Some other queries i need

2. Delete all EasySocial posts older than X days or months
3. Delete all EasySocial notifications older than x days or months
* it would be useful 2 types of queries one for "older then X days" and another one for "older than x months"

Any tip ? Thanks !
Hello,

You may use the datediff() function in MySQL to delete


delete from jos_social_stream where actor_id="REPLACE_WITH_USER_ID" and actor_type="user" and datediff( now(), created) >= 30;


The above query will delete users posts where the creation date of the posts is older than 30 days.

Hope this help and have a nice day
Sam
·
Tuesday, 01 April 2014 20:32
·
0 Likes
·
0 Votes
·
0 Comments
·
Thanks for sharing this Sam.

Can you also share an example to delete all EasySocial posts older than 30 days (not user id specific but all post from all users) .. and also, all EasySocial notifications older than 30 days ?

Thanks, it really helps us a lot since we are not using EasySocial as primary focus on our project and these queries can help us out to purge old stuff.
·
Tuesday, 01 April 2014 20:41
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Mist,

If you just want to delete all posts which is older than 30 days, run the query below:


delete from jos_social_stream where datediff( now(), created) >= 30;
·
Tuesday, 01 April 2014 23:50
·
0 Likes
·
0 Votes
·
0 Comments
·
Great, thanks Mark !

So, i assume that for deleting all notifications older than 30 days this query will work

delete from jos_social_notifications where datediff( now(), created) >= 30;
·
Wednesday, 02 April 2014 00:55
·
0 Likes
·
0 Votes
·
0 Comments
·
Yes that's correct
·
Wednesday, 02 April 2014 01:14
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post