remove orphaned version tags

This commit is contained in:
Doug Bell 2009-09-01 22:25:22 +00:00
parent d8ae7fc68e
commit c671e94056

View file

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