
jbrandt at bestpractical
Jul 26, 2012, 11:45 AM
Post #1 of 1
(64 views)
Permalink
|
|
rt branch, 4.2/upgrade-history, updated. rt-4.0.5-297-gac0cf0a
|
|
The branch, 4.2/upgrade-history has been updated via ac0cf0af56571f79c563e7ccd4fe6d0d3c6347cb (commit) from 05eb3685f42ef9b5935816d70c0984cc32df6984 (commit) Summary of changes: lib/RT/System.pm | 20 ++++++++++---------- sbin/rt-setup-database.in | 34 +++++++++++++++++++++++++++------- 2 files changed, 37 insertions(+), 17 deletions(-) - Log ----------------------------------------------------------------- commit ac0cf0af56571f79c563e7ccd4fe6d0d3c6347cb Author: Jim Brandt <jbrandt [at] bestpractical> Date: Thu Jul 26 14:40:09 2012 -0400 Add component and version options to rt-setup-database for upgrade history Rename realm to component and allow this value to be passed as an argument to rt-setup-database. This allows extensions to store upgrade history under their own key. Add a ext-version argument for extension version and add this as an optional entry in the upgrade hash. Module::Install::RTx needs updates to use these new options for make initdb. diff --git a/lib/RT/System.pm b/lib/RT/System.pm index f2ff57e..409ebed 100644 --- a/lib/RT/System.pm +++ b/lib/RT/System.pm @@ -260,7 +260,7 @@ sub QueueCacheNeedsUpdate { =head2 AddUpgradeHistory realm, data -Adds an entry to the upgrade history database. The realm can be either C<RT> +Adds an entry to the upgrade history database. The component can be either C<RT> for core RT upgrades, or the fully qualified name of a plugin. The data must be a hash reference. @@ -268,7 +268,7 @@ a hash reference. sub AddUpgradeHistory { my $self = shift; - my $realm = shift; + my $component = shift; my $data = shift; $data->{timestamp} ||= time; @@ -277,7 +277,7 @@ sub AddUpgradeHistory { my $upgrade_history_attr = $self->FirstAttribute('UpgradeHistory'); my $upgrade_history = $upgrade_history_attr ? $upgrade_history_attr->Content : {}; - push @{ $upgrade_history->{$realm} }, $data; + push @{ $upgrade_history->{$component} }, $data; $self->SetAttribute( Name => 'UpgradeHistory', @@ -285,23 +285,23 @@ sub AddUpgradeHistory { ); } -=head2 UpgradeHistory [realm] +=head2 UpgradeHistory [component] -Returns the entries of RT's upgrade history. If a realm is specified, the list -of upgrades for that realm will be returned. Otherwise a hash reference of -C<< realm => [upgrades] >> will be returned. +Returns the entries of RT's upgrade history. If a component is specified, the list +of upgrades for that component will be returned. Otherwise a hash reference of +C<< component => [upgrades] >> will be returned. =cut sub UpgradeHistory { my $self = shift; - my $realm = shift; + my $component = shift; my $upgrade_history_attr = $self->FirstAttribute('UpgradeHistory'); my $upgrade_history = $upgrade_history_attr ? $upgrade_history_attr->Content : {}; - if ($realm) { - return @{ $upgrade_history->{$realm} || [] }; + if ($component) { + return @{ $upgrade_history->{$component} || [] }; } return $upgrade_history; diff --git a/sbin/rt-setup-database.in b/sbin/rt-setup-database.in index e137aee..31ad3a2 100755 --- a/sbin/rt-setup-database.in +++ b/sbin/rt-setup-database.in @@ -82,6 +82,7 @@ GetOptions( 'force', 'debug', 'dba=s', 'dba-password=s', 'prompt-for-dba-password', 'datafile=s', 'datadir=s', 'skip-create', 'root-password-file=s', + 'component=s', 'ext-version=s', 'help|h', ); @@ -185,6 +186,9 @@ print "Working with:\n" ."Type:\t$db_type\nHost:\t$db_host\nName:\t$db_name\n" ."User:\t$db_user\nDBA:\t$dba_user" . ($args{'skip-create'} ? ' (No DBA)' : '') . "\n"; +my $component = $args{'component'} || 'RT'; +my $ext_version = $args{'ext-version'}; + foreach my $action ( @actions ) { no strict 'refs'; my ($status, $msg) = *{ 'action_'. $action }{'CODE'}->( %args ); @@ -303,12 +307,15 @@ sub action_insert { RT->ConnectToDatabase(); - RT->System->AddUpgradeHistory(RT => { + my %upgrade_data = ( action => 'insert', filename => $file, content => $content, - stage => 'after', - }); + stage => 'after',); + + $upgrade_data{'ext_version'} = $ext_version if $ext_version; + + RT->System->AddUpgradeHistory($component => \%upgrade_data); my $db_type = RT->Config->Get('DatabaseType'); $RT::Handle->Disconnect() unless $db_type eq 'SQLite'; @@ -401,7 +408,7 @@ sub action_upgrade { RT->InitLogging(); RT->InitSystemObjects(); - RT->System->AddUpgradeHistory(RT => { + RT->System->AddUpgradeHistory($component => { type => 'full upgrade', action => 'upgrade', stage => 'before', @@ -417,7 +424,7 @@ sub action_upgrade { my @back = grep {-e $_} map {"$base_dir/$versions[$_]/backcompat"} $n+1..$#versions; print "Processing $v\n"; - RT->System->AddUpgradeHistory(RT => { + RT->System->AddUpgradeHistory($component => { action => 'upgrade', type => 'individual upgrade', stage => 'before', @@ -445,7 +452,7 @@ sub action_upgrade { RT->ConnectToDatabase(); - RT->System->AddUpgradeHistory(RT => { + RT->System->AddUpgradeHistory($component => { action => 'upgrade', type => 'individual upgrade', stage => 'after', @@ -456,7 +463,7 @@ sub action_upgrade { $previous = $v; } - RT->System->AddUpgradeHistory(RT => { + RT->System->AddUpgradeHistory($component => { type => 'full upgrade', action => 'upgrade', stage => 'after', @@ -650,4 +657,17 @@ administrator privileges for 'init' and 'insert': rather than using the default administrative password for RT's "root" user, use the password in this file. +=item component + +the name of the entity performing a create or upgrade. Used for logging changes +in the DB. Defaults to RT, but can be the name of an extension or plugin making +changes to the DB. + +=item ext-version + +current version of extension making a change. Not needed for RT since RT has a +more elaborate system to track upgrades across multiple versions. + =back + +=cut ----------------------------------------------------------------------- _______________________________________________ Rt-commit mailing list Rt-commit [at] lists http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-commit
|