RT#39694: Evariste CDRs [Evariste TKT #2140] [fixed dates]
[freeside.git] / FS / bin / freeside-upgrade
index b2cd3db..dd20688 100755 (executable)
@@ -5,7 +5,7 @@ use vars qw( $opt_d $opt_s $opt_q $opt_v $opt_r $opt_c $opt_j $opt_a );
 use vars qw( $DEBUG $DRY_RUN );
 use Getopt::Std;
 use DBD::Pg qw(:async); #for -a
-use DBIx::DBSchema 0.31; #0.39
+use DBIx::DBSchema 0.46;
 use FS::UID qw(adminsuidsetup checkeuid datasrc driver_name);
 use FS::CurrentUser;
 use FS::Schema qw( dbdef dbdef_dist reload_dbdef );
@@ -94,10 +94,19 @@ if ( dbdef->table('areacode') and
 }
 
 if ( dbdef->table('upgrade_journal') ) {
-  push @bugfix, "SELECT SETVAL( 'upgrade_journal_upgradenum_seq',
-                                ( SELECT MAX(upgradenum) FROM upgrade_journal )
-                              )
-                ";
+  if ( driver_name =~ /^Pg/i ) {
+    push @bugfix, "
+      SELECT SETVAL( 'upgrade_journal_upgradenum_seq',
+                     ( SELECT MAX(upgradenum) FROM upgrade_journal )
+                   )
+    ";
+  #MySQL can't do this in a statement so have to do it manually
+  #} elsif ( driver_name =~ /^mysql/i ) {
+  #  push @bugfix, "
+  #     ALTER TABLE upgrade_journal AUTO_INCREMENT =
+  #                 ( ( SELECT MAX(upgradenum) FROM upgrade_journal ) + 1 )
+  #  ";
+  }
 }
 
 if ( $DRY_RUN ) {
@@ -456,14 +465,13 @@ Also performs other upgrade functions:
           current default.
 
   [ -s ]: Schema changes only.  Useful for Pg/slony slaves where the data
+          changes will be replicated from the Pg/slony master.
 
   [ -r ]: Skip sqlradius updates.  Useful for occassions where the sqlradius
           databases may be inaccessible.
 
   [ -c ]: Skip cdr and h_cdr updates.
 
-          changes will be replicated from the Pg/slony master.
-
   [ -j ]: Run certain upgrades asychronously from the job queue.  Currently 
           used only for the 2.x -> 3.x cust_location, cust_pay and part_pkg
           upgrades.  This may cause odd behavior before the upgrade is