[Rt-commit] rt branch, 4.2/dashboard-tables, updated. rt-4.0.0rc6-175-g3b9971b
Shawn Moore
sartak at bestpractical.com
Mon Mar 21 11:15:37 EDT 2011
The branch, 4.2/dashboard-tables has been updated
via 3b9971b2f51676d153fc32b76b5bbf3f86b74dc8 (commit)
from 8f7baddf7c4e6ad028a73f9fd034f15338bdbaaa (commit)
Summary of changes:
etc/upgrade/4.1.1/content | 31 ++++++++++++++++++++++++++++---
1 files changed, 28 insertions(+), 3 deletions(-)
- Log -----------------------------------------------------------------
commit 3b9971b2f51676d153fc32b76b5bbf3f86b74dc8
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Mon Mar 21 11:15:28 2011 -0400
Upgrade subscriptions when we recreate dashboards
diff --git a/etc/upgrade/4.1.1/content b/etc/upgrade/4.1.1/content
index 15586e5..902230b 100644
--- a/etc/upgrade/4.1.1/content
+++ b/etc/upgrade/4.1.1/content
@@ -1,7 +1,11 @@
+my %new_id_for;
+
my $convert_attributes = sub {
my $obj = shift;
for my $attribute ($obj->Attributes->Named('Dashboard')) {
+ my $attr_id = $attribute->id;
+
my $dashboard = RT::Dashboard->new($RT::SystemUser);
my ($ok, $msg) = $dashboard->Create(
@@ -12,18 +16,20 @@ my $convert_attributes = sub {
);
if (!$ok) {
- $RT::Logger->error("Unable to reify attribute " . $attr->id . " into a dashboard: $msg");
+ $RT::Logger->error("Unable to reify attribute $attr_id into a dashboard: $msg");
next;
}
+ $new_id_for{$attr_id} = $dashboard->id;
+
($ok, $msg) = $attr->Delete;
if (!$ok) {
- $RT::Logger->error("Reified attribute into dashboard " . $dashboard->id . " but couldn't delete attribute: $msg");
+ $RT::Logger->error("Reified attribute $attr_id into dashboard " . $dashboard->id . " but couldn't delete attribute: $msg");
next;
}
- $RT::Logger->debug("Reified attribute into a dashboard: $msg");
+ $RT::Logger->debug("Reified attribute $attr_id into a dashboard: $msg");
}
};
@@ -48,5 +54,24 @@ my $convert_attributes = sub {
my $system = RT::System->new($RT::SystemUser);
$convert_attributes->($system);
},
+
+ sub {
+ my $users = RT::Users->new($RT::SystemUser);
+ $users->UnLimit;
+
+ while (my $user = $users->Next) {
+ for my $subscription ($users->Attributes->Named('Subscription')) {
+ my $old_id = $subscription->SubValue('DashboardId');
+ my $new_id = $new_id_for{$old_id};
+
+ if (!$new_id) {
+ $RT::Logger->error("Can't update subscription " . $subscription->id . " for old-style dashboard $old_id since it has no new-style ID");
+ next;
+ }
+
+ $subscription->SetSubValue(DashboardId => $new_id);
+ }
+ }
+ },
);
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list