[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[3933] branches/1.3



Revision: 3933
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3933&view=rev
Author:   einhverfr
Date:     2011-10-27 12:26:47 +0000 (Thu, 27 Oct 2011)
Log Message:
-----------
Database upgrade now necessary and supported through setup.pl

Modified Paths:
--------------
    branches/1.3/LedgerSMB/Form.pm
    branches/1.3/LedgerSMB.pm
    branches/1.3/scripts/setup.pl

Modified: branches/1.3/LedgerSMB/Form.pm
===================================================================
--- branches/1.3/LedgerSMB/Form.pm	2011-10-26 23:49:33 UTC (rev 3932)
+++ branches/1.3/LedgerSMB/Form.pm	2011-10-27 12:26:47 UTC (rev 3933)
@@ -151,7 +151,7 @@
     $self->{lynx} = 1 if ( ( defined $self->{path} ) && ( $self->{path} =~ /lynx/i ) );
 
     $self->{version}   = "1.3.2";
-    $self->{dbversion} = "1.3.0";
+    $self->{dbversion} = "1.3.3";
 
     bless $self, $type;
 

Modified: branches/1.3/LedgerSMB.pm
===================================================================
--- branches/1.3/LedgerSMB.pm	2011-10-26 23:49:33 UTC (rev 3932)
+++ branches/1.3/LedgerSMB.pm	2011-10-27 12:26:47 UTC (rev 3933)
@@ -238,7 +238,7 @@
     $logger->debug("Begin LedgerSMB.pm");
 
     $self->{version} = $VERSION;
-    $self->{dbversion} = "1.3.0";
+    $self->{dbversion} = "1.3.3";
     
     bless $self, $type;
     $logger->debug("LedgerSMB::new: \$argstr = $argstr");

Modified: branches/1.3/scripts/setup.pl
===================================================================
--- branches/1.3/scripts/setup.pl	2011-10-26 23:49:33 UTC (rev 3932)
+++ branches/1.3/scripts/setup.pl	2011-10-27 12:26:47 UTC (rev 3933)
@@ -89,7 +89,15 @@
             );
             $request->{operation} = $request->{_locale}->text('Cancel?');
             $request->{next_action} = 'cancel';
-            
+         
+         } elsif ($version_info->{version} eq '1.3') {
+             $request->{message} = $request->{_locale}->text(
+                 'LedgerSMB 1.3 found'   
+             );
+             $request->{operation} = $request->{_locale}->text(
+                    'Rebuild/Upgrade?'
+             );
+             $request->{next_action} = 'rebuild_modules';
          } else {
             $request->{message} = $request->{_locale}->text(
                  'Unknown version found.'
@@ -497,7 +505,7 @@
         my $template = LedgerSMB::Template->new(
                 path => 'UI/setup',
                 template => 'new_user',
-         format => 'HTML',
+                format => 'HTML',
         );
         $template->render($request);
         exit;        
@@ -615,6 +623,48 @@
     __default(@_);
 }
 
+=item rebuild_modules
+
+This method rebuilds the modules and sets the version setting in the defaults
+table to the version of the LedgerSMB request object.  This is used when moving
+between versions on a stable branch (typically upgrading)
+
+=cut
+
+sub rebuild_modules {
+    my ($request) = @_;
+    my $creds = LedgerSMB::Auth::get_credentials();
+    my $database = LedgerSMB::Database->new(
+               {username => $creds->{username},
+            company_name => $request->{database},
+                password => $creds->{password}}
+    );
+
+    # ENVIRONMENT NECESSARY
+    $ENV{PGUSER} = $creds->{login};
+    $ENV{PGPASSWORD} = $creds->{password};
+    $ENV{PGDATABASE} = $request->{database};
+    
+    $database->load_modules('LOADORDER');
+    # Credentials set above via environment variables --CT
+    $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}");
+    my $dbh = $request->{dbh};
+    my $sth = $dbh->prepare(
+          'UPDATE defaults SET value = ? WHERE setting_key = ?'
+    );
+    $sth->execute($request->{dbversion}, 'version');
+    $sth->finish;
+    $dbh->commit;
+    $dbh->disconnect;
+    my $template = LedgerSMB::Template->new(
+            path => 'UI/setup',
+            template => 'complete',
+            format => 'HTML',
+    );
+    $template->render($request);
+
+}
+
 =back
 
 =head1 COPYRIGHT

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.