[Rt-commit] rt branch, 4.2/version-history-bootstrapping, created. rt-4.2.0rc1-14-g403a02f

Alex Vandiver alexmv at bestpractical.com
Thu Sep 19 19:41:49 EDT 2013


The branch, 4.2/version-history-bootstrapping has been created
        at  403a02fe2f2703e8a0f10e7ca8c7a0a523dab678 (commit)

- Log -----------------------------------------------------------------
commit a1861fc3b1bf956e3daf12b114a0c6455513d036
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu Sep 19 19:15:00 2013 -0400

    Add upgrade history only if the database is known to be fully set up
    
    Adding upgrade history entries requires that the tables have been
    created and ACL'd, and that the coredata have been inserted.  'init' is
    not the only way to be prior to that state -- the create and ACL states
    can be run by hand, for instance.
    
    Instead of assuming that the database _is_ sufficiently configured,
    assume rather that is it not, and thus default to not logging upgrade
    history attributes.  Only in cases where InitSystemObjects has already
    been called (upgrades and non-coredata insertions) do we have a
    guarantee that the database is sufficiently configured, and thus enable
    upgrade history logging from then on.

diff --git a/sbin/rt-setup-database.in b/sbin/rt-setup-database.in
index d913e16..5f7723e 100644
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -196,6 +196,8 @@ my $package = $args{'package'} || 'RT';
 my $ext_version = $args{'ext-version'};
 my $full_id = Data::GUID->new->as_string;
 
+my $log_actions = 0;
+
 foreach my $action ( @actions ) {
     no strict 'refs';
     my ($status, $msg) = *{ 'action_'. $action }{'CODE'}->( %args );
@@ -247,7 +249,7 @@ sub action_schema {
         individual_id => $individual_id,
     );
     $upgrade_data{'ext_version'} = $ext_version if $ext_version;
-    RT->System->AddUpgradeHistory($package => \%upgrade_data) unless $init;
+    RT->System->AddUpgradeHistory($package => \%upgrade_data) if $log_actions;
 
     print "Now populating database schema.\n";
     my @ret = RT::Handle->InsertSchema( $dbh, $args{'datafile'} || $args{'datadir'} );
@@ -257,7 +259,7 @@ sub action_schema {
         individual_id => $individual_id,
         return_value  => [ @ret ],
     );
-    RT->System->AddUpgradeHistory($package => \%upgrade_data) unless $init;
+    RT->System->AddUpgradeHistory($package => \%upgrade_data) if $log_actions;
 
     return @ret;
 }
@@ -277,7 +279,7 @@ sub action_acl {
         individual_id => $individual_id,
     );
     $upgrade_data{'ext_version'} = $ext_version if $ext_version;
-    RT->System->AddUpgradeHistory($package => \%upgrade_data) unless $init;
+    RT->System->AddUpgradeHistory($package => \%upgrade_data) if $log_actions;
 
     print "Now inserting database ACLs.\n";
     my @ret = RT::Handle->InsertACL( $dbh, $args{'datafile'} || $args{'datadir'} );
@@ -287,7 +289,7 @@ sub action_acl {
         individual_id => $individual_id,
         return_value  => [ @ret ],
     );
-    RT->System->AddUpgradeHistory($package => \%upgrade_data) unless $init;
+    RT->System->AddUpgradeHistory($package => \%upgrade_data) if $log_actions;
 
     return @ret;
 }
@@ -304,7 +306,7 @@ sub action_indexes {
         individual_id => $individual_id,
     );
     $upgrade_data{'ext_version'} = $ext_version if $ext_version;
-    RT->System->AddUpgradeHistory($package => \%upgrade_data);
+    RT->System->AddUpgradeHistory($package => \%upgrade_data) if $log_actions;
 
     my $dbh = get_admin_dbh();
     $RT::Handle = RT::Handle->new;
@@ -322,7 +324,7 @@ sub action_indexes {
         individual_id => $individual_id,
         return_value  => [ @ret ],
     );
-    RT->System->AddUpgradeHistory($package => \%upgrade_data);
+    RT->System->AddUpgradeHistory($package => \%upgrade_data) if $log_actions;
 
     return @ret;
 }
@@ -343,6 +345,8 @@ sub action_insert {
     my %args = @_;
     $RT::Handle = RT::Handle->new;
     RT::Init();
+    $log_actions = 1;
+
     my ($status, $msg) = RT::Handle->CheckCompatibility( $RT::Handle->dbh, 'insert' );
     return ($status, $msg) unless $status;
 
@@ -485,6 +489,7 @@ sub action_upgrade {
 
     RT->ConnectToDatabase();
     RT->InitSystemObjects();
+    $log_actions = 1;
 
     RT->System->AddUpgradeHistory($package => {
         type      => 'full upgrade',

commit 403a02fe2f2703e8a0f10e7ca8c7a0a523dab678
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu Sep 19 19:38:16 2013 -0400

    Enable upgrade history logging for all non-RT database changes
    
    There is one further condition, in addition to those in the previous
    commit, under which we can be certain that the RT database is
    sufficiently configured; namely, in the case of database changes for
    extensions.  While logging for 'insert' actions in extensions is already
    covered by the previous logic, 'acl' actions were not.
    
    Explicitly connect and set up system objects when conducting database
    changes for extensions; this then allows database upgrade steps to be
    logged.

diff --git a/sbin/rt-setup-database.in b/sbin/rt-setup-database.in
index 5f7723e..0995457 100644
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -197,6 +197,11 @@ my $ext_version = $args{'ext-version'};
 my $full_id = Data::GUID->new->as_string;
 
 my $log_actions = 0;
+if ($args{'package'} ne 'RT') {
+    RT->ConnectToDatabase();
+    RT->InitSystemObjects();
+    $log_actions = 1;
+}
 
 foreach my $action ( @actions ) {
     no strict 'refs';

-----------------------------------------------------------------------


More information about the Rt-commit mailing list