From c671e940563a1f7665746fc4940016d2b16739a9 Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Tue, 1 Sep 2009 22:25:22 +0000 Subject: [PATCH] remove orphaned version tags --- docs/upgrades/upgrade_7.7.18-7.7.19.pl | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/upgrades/upgrade_7.7.18-7.7.19.pl b/docs/upgrades/upgrade_7.7.18-7.7.19.pl index ae73a2283..313593062 100644 --- a/docs/upgrades/upgrade_7.7.18-7.7.19.pl +++ b/docs/upgrades/upgrade_7.7.18-7.7.19.pl @@ -37,6 +37,7 @@ addInboxSmsNotificationTemplateIdSetting($session); upgradeJSONDatabaseFields($session); moveCalendarFeedsToJSON($session); addEmsScheduleColumnsDefaultValue($session); +removeOrphanedVersionTags( $session ); finish($session); # this line required #---------------------------------------------------------------------------- @@ -131,6 +132,28 @@ sub moveCalendarFeedsToJSON { print "DONE!\n" unless $quiet; } +#---------------------------------------------------------------------------- +# Remove the orphan version tags, tags with no revisions in them +sub removeOrphanedVersionTags { + my $session = shift; + print "\tRemoving orphan version tags (this may take a while)... " unless $quiet; + + my $sth = $session->db->read( + "SELECT tagId FROM assetVersionTag", + ); + while ( my ($tagId) = $sth->array ) { + if ( !$session->db->quickScalar( + "SELECT COUNT(*) FROM assetData WHERE tagId=?", + [ $tagId ] + ) ) { + my $tag = WebGUI::VersionTag->new( $session, $tagId ); + $tag->rollback; + } + } + + print "DONE!\n" unless $quiet; +} + # -------------- DO NOT EDIT BELOW THIS LINE -------------------------------- #----------------------------------------------------------------------------