fix: 7.2.3-7.3.0 upgrade now migrates EC and Events in the Trash and Clipboard
This commit is contained in:
parent
bd7ef8d14e
commit
6e06db64a2
4 changed files with 72 additions and 2 deletions
|
|
@ -214,6 +214,8 @@ sub migrateCalendars {
|
|||
#EventsCalendar.defaultMonth = Calendar.defaultDate
|
||||
my $calendars = WebGUI::Asset->getRoot($session)->getLineage(['descendents'],
|
||||
{
|
||||
statesToInclude => ['published','trash','clipboard','clipboard-limbo','trash-limbo'],
|
||||
statusToInclude => ['pending','approved','deleted','archived'],
|
||||
includeOnlyClasses => ['WebGUI::Asset::Wobject::EventsCalendar'],
|
||||
returnObjects => 1,
|
||||
});
|
||||
|
|
@ -226,14 +228,21 @@ sub migrateCalendars {
|
|||
#warn "Found calendar ".$properties->{title};
|
||||
$properties->{className} = "WebGUI::Asset::Wobject::Calendar";
|
||||
|
||||
|
||||
use Data::Dumper;
|
||||
warn Dumper $properties;
|
||||
|
||||
# Add the new asset
|
||||
my $newAsset = $asset->getParent->addChild($properties);
|
||||
#warn "Added Calendar ".$newAsset->get("title")." ".$newAsset->get("className");
|
||||
|
||||
|
||||
warn Dumper $asset->get;
|
||||
warn "\n\n\n\n\n\n\n\n";
|
||||
|
||||
# Get this calendar's events and change to new parent
|
||||
my $events = $asset->getLineage(['descendants'],
|
||||
{
|
||||
statesToInclude => ['published','trash','clipboard','clipboard-limbo','trash-limbo'],
|
||||
statusToInclude => ['pending','approved','deleted','archived'],
|
||||
includeOnlyClasses => ['WebGUI::Asset::Event'],
|
||||
});
|
||||
#warn "Got lineage";
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ my $quiet; # this line required
|
|||
my $session = start(); # this line required
|
||||
|
||||
# upgrade functions go here
|
||||
removeOrphanedEventsCalendars($session);
|
||||
removeOrphanedEvents($session);
|
||||
|
||||
finish($session); # this line required
|
||||
|
||||
|
|
@ -32,6 +34,49 @@ finish($session); # this line required
|
|||
# # and here's our code
|
||||
#}
|
||||
|
||||
##-------------------------------------------------
|
||||
sub removeOrphanedEventsCalendars {
|
||||
my $session = shift;
|
||||
print "\tRemoving orphaned Events Calendars... ";
|
||||
|
||||
# Remove Events Calendars from asset, assetData, assetIndex, wobject
|
||||
my @assetIds
|
||||
= $session->db->buildArray(
|
||||
qq{select assetId from asset where className="WebGUI::Asset::Wobject::EventsCalendar"}
|
||||
);
|
||||
|
||||
for my $assetId (@assetIds) {
|
||||
for my $table (qw( assetData assetIndex wobject asset )) {
|
||||
$session->db->write("delete from $table where assetId=?",[$assetId]);
|
||||
}
|
||||
}
|
||||
|
||||
print "OK!\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
##-------------------------------------------------
|
||||
sub removeOrphanedEvents {
|
||||
my $session = shift;
|
||||
print "\tRemoving orphaned Events... ";
|
||||
|
||||
# Remove Events from asset, assetData, assetIndex that do not exist in the Event table
|
||||
my @assetIds
|
||||
= $session->db->buildArray(
|
||||
qq{select assetId from asset where className="WebGUI::Asset::Event" }
|
||||
. qq{and assetId NOT IN (select assetId from Event)}
|
||||
);
|
||||
|
||||
for my $assetId (@assetIds) {
|
||||
for my $table (qw( assetData assetIndex asset )) {
|
||||
$session->db->write("delete from $table where assetId=?",[$assetId]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
print "OK!\n";
|
||||
}
|
||||
|
||||
|
||||
# ---- DO NOT EDIT BELOW THIS LINE ----
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue