"Leftover" images

Vote:
 

In my development environment I have som images created by a now deleted user. These images causes exceptions to be thrown when I try to access the image gallery.

How can I get rid of these images without ruining the database? 

#31001
Jun 30, 2009 9:54
Vote:
 

Hi Claus,

These images should have been removed when the user was removed. But anyways... First run this SQL script:

DELETE FROM tblEPiServerCommunityImageGalleryImage
WHERE intUploaderID NOT IN (SELECT intID FROM tblEPiServerCommonUser)

 

This will delete all the images. Then you will probably have to update the counters on the image galleries as well. This is done with the following scripts:

UPDATE tblEPiServerCommunityImageGallery
SET intNumOfImagesTotal =
(SELECT COUNT(*) FROM tblEPiServerCommunityImageGalleryImage
WHERE intImageGalleryID = tblEPiServerCommunityImageGallery.intID)

UPDATE tblEPiServerCommunityImageGallery
SET intNumOfImagesPublished =
(SELECT COUNT(*) FROM tblEPiServerCommunityImageGalleryImage
WHERE intImageGalleryID = tblEPiServerCommunityImageGallery.intID
AND intPublishState = 1
)

UPDATE tblEPiServerCommunityImageGallery
SET intNumOfImagesNotPublished =
(SELECT COUNT(*) FROM tblEPiServerCommunityImageGalleryImage
WHERE intImageGalleryID = tblEPiServerCommunityImageGallery.intID
AND intPublishState = 2
)

Probably best to take a backup of database before you this, just in case ;)

Best regards,
Tom

 

#31080
Jul 01, 2009 15:04
Vote:
 

Great! Thanks, Tom.

Best regards

Claus

#31152
Jul 06, 2009 13:26
Vote:
 

Great! Thanks, Tom.

Best regards

Claus

#31153
Jul 06, 2009 13:26
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.