MG 1.1 How to delete all empty albums

Alpha1

Well-known member
After migration from vbulletin albums, LDM and photopost I have a large number of empty albums on my site.
Is there a query that I can use to delete all empty albums from my site?
 
First it's important to ensure all of the album counts are up to date. These aren't rebuild automatically in all cases (after an import), and therefore it's possible there are fewer empty albums than you expect. It's an important step, because the query I'm about to give you assumes this count will be correct.

The correct rebuild to run to make sure of this is Admin CP > Applications > Gallery Rebuilds and search for the one named "Rebuild XenForo Media Gallery Album Media Count" (some of them have sort of similar names, so double check this!

Once that has been completed, you can just run this query:

Code:
DELETE FROM xengallery_album WHERE album_media_count = 0

After completing that, you will need to run the "Rebuild XenForo Media Gallery User Album Counts" rebuild, this will update the info in xf_user to ensure that a user's album count is correct.
 
Last edited:
The correct rebuild to run to make sure of this is Admin CP > Applications > Gallery Rebuilds and search for the one named "Rebuild XenForo Media Gallery Album Media Count" (some of them have sort of similar names, so double check this!

In XF 2 this is included in XFMG: Rebuild albums?

New Code:
Code:
DELETE FROM xf_mg_album WHERE media_count  = 0
 
Back
Top Bottom