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 -------------------------------- #----------------------------------------------------------------------------