[Rt-commit] [rtir] 01/01: Add a make upgrade-database command

Kevin Falcone falcone at bestpractical.com
Tue Jun 25 18:17:36 EDT 2013


This is an automated email from the git hooks/post-receive script.

falcone pushed a commit to branch 2.9/make-upgrade-database
in repository rtir.

commit 44f0608f6bdaaeec9a516972268bb123c0bd26e9
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Fri Jun 7 18:41:01 2013 -0400

    Add a make upgrade-database command
    
    This makes use of Module::Install::RTx's make-upgrade branch as well as
    RT's 4.0/customize-upgrade-wordings.
---
 inc/Module/Install/RTx.pm         | 9 ++++++++-
 inc/Module/Install/RTx/Factory.pm | 6 +++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/inc/Module/Install/RTx.pm b/inc/Module/Install/RTx.pm
index c9fe996..e5558d4 100644
--- a/inc/Module/Install/RTx.pm
+++ b/inc/Module/Install/RTx.pm
@@ -136,6 +136,7 @@ install ::
         $has_etc{acl}++;
     }
     if ( -e 'etc/initialdata' ) { $has_etc{initialdata}++; }
+    if ( -d 'etc/upgrade/' )    { $has_etc{upgrade}++; }
 
     $self->postamble("$postamble\n");
     unless ( $subdirs{'lib'} ) {
@@ -164,6 +165,12 @@ install ::
 .
         $self->postamble("initdb ::\n$initdb\n");
         $self->postamble("initialize-database ::\n$initdb\n");
+        if ($has_etc{upgrade}) {
+            print "To upgrade from a previous version of this extension, use 'make upgrade-database'\n";
+            my $upgradedb = qq|\t\$(NOECHO) \$(PERL) -Ilib -I"$local_lib_path" -I"$lib_path" -Minc::Module::Install -e"RTxInitDB(qw(upgrade \$(NAME) \$(VERSION)))"\n|;
+            $self->postamble("upgrade-database ::\n$upgradedb\n");
+            $self->postamble("upgradedb ::\n$upgradedb\n");
+        }
     }
 }
 
@@ -209,4 +216,4 @@ sub requires_rt {
 
 __END__
 
-#line 329
+#line 336
diff --git a/inc/Module/Install/RTx/Factory.pm b/inc/Module/Install/RTx/Factory.pm
index 76ab761..8015792 100644
--- a/inc/Module/Install/RTx/Factory.pm
+++ b/inc/Module/Install/RTx/Factory.pm
@@ -32,12 +32,16 @@ sub RTxInitDB {
         "-I$lib_path",
         "$RT::SbinPath/rt-setup-database",
         "--action"      => $action,
-        "--datadir"     => "etc",
+        ($action eq 'upgrade' ? () : ("--datadir"     => "etc")),
         (($action eq 'insert') ? ("--datafile"    => "etc/initialdata") : ()),
         "--dba"         => $RT::DatabaseAdmin || $RT::DatabaseUser,
         "--prompt-for-dba-password" => '',
         (RT::System->can('AddUpgradeHistory') ? ("--package" => $name, "--ext-version" => $version) : ()),
     );
+    if ($action eq 'upgrade' and
+        not RT::System->can('AddUpgradeHistory')) {
+        push @args, "--package" => $name;
+    }
 
     print "$^X @args\n";
     (system($^X, @args) == 0) or die "...returned with error: $?\n";

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Rt-commit mailing list