MySQL support, RT#28895
authorIvan Kohler <ivan@freeside.biz>
Fri, 30 May 2014 21:04:10 +0000 (14:04 -0700)
committerIvan Kohler <ivan@freeside.biz>
Fri, 30 May 2014 21:04:10 +0000 (14:04 -0700)
FS/FS/Schema.pm
FS/FS/TicketSystem.pm
FS/FS/tower_sector.pm
FS/bin/freeside-upgrade
httemplate/edit/process/tower.html
httemplate/edit/tower.html
httemplate/elements/tower_sector.html

index 71bdec9..95de553 100644 (file)
@@ -3161,16 +3161,16 @@ sub tables_hashref {
 
     'tower_sector' => {
       'columns' => [
-        'sectornum',   'serial',     '',      '', '', '',
-        'towernum',       'int',     '',      '', '', '',
-        'sectorname', 'varchar',     '', $char_d, '', '',
-        'ip_addr',    'varchar', 'NULL',      15, '', '',
-        'height',     'decimal', 'NULL',      '', '', '', 
-        'freq_mhz',       'int', 'NULL',      '', '', '',
-        'direction',      'int', 'NULL',      '', '', '',
-        'width',          'int', 'NULL',      '', '', '',
+        'sectornum',     'serial',     '',      '', '', '',
+        'towernum',         'int',     '',      '', '', '',
+        'sectorname',   'varchar',     '', $char_d, '', '',
+        'ip_addr',      'varchar', 'NULL',      15, '', '',
+        'height',       'decimal', 'NULL',      '', '', '', 
+        'freq_mhz',         'int', 'NULL',      '', '', '',
+        'direction',        'int', 'NULL',      '', '', '',
+        'width',            'int', 'NULL',      '', '', '',
         #downtilt etc? rfpath has profile files for devices/antennas you upload?
-        'range',      'decimal', 'NULL',      '', '', '',  #?
+        'sector_range', 'decimal', 'NULL',      '', '', '',  #?
       ],
       'primary_key' => 'sectornum',
       'unique'      => [ [ 'towernum', 'sectorname' ], [ 'ip_addr' ], ],
index 3c972d0..7339d74 100644 (file)
@@ -331,16 +331,24 @@ sub _upgrade_data {
     }
   }
 
-  #Pg-specific 
-  my $cve_2013_3373_sql = q(
-    UPDATE Tickets SET Subject = REPLACE(Subject,E'\n','')
-  );
-  #need this for mysql
-  #UPDATE Tickets SET Subject = REPLACE(Subject,'\n','');
-
-  my $cve_2013_3373_sth = $dbh->prepare( $cve_2013_3373_sql)
-    or die $dbh->errstr;
-  $cve_2013_3373_sth->execute or die $cve_2013_3373_sth->errstr;
+  my $cve_2013_3373_sql = '';
+  if ( driver_name =~ /^Pg/i ) {
+    $cve_2013_3373_sql = q(
+      UPDATE Tickets SET Subject = REPLACE(Subject,E'\n','')
+    );
+  } elsif ( driver_name =~ /^mysql/i ) {
+    $cve_2013_3373_sql = q(
+      UPDATE Tickets SET Subject = REPLACE(Subject,'\n','');
+    );
+  } else {
+    warn "WARNING: Don't know how to update RT Ticket Subjects for your database driver for CVE-2013-3373";
+  }
+  if ( $cve_2013_3373_sql ) {
+    my $cve_2013_3373_sth = $dbh->prepare($cve_2013_3373_sql)
+      or die $dbh->errstr;
+    $cve_2013_3373_sth->execute
+      or die $cve_2013_3373_sth->errstr;
+  }
 
   # Remove dangling customer links, if any
   my %target_pkey = ('cust_main' => 'custnum', 'cust_svc' => 'svcnum');
index 70642fb..4a6525e 100644 (file)
@@ -112,7 +112,7 @@ sub check {
     || $self->ut_numbern('freq_mhz')
     || $self->ut_numbern('direction')
     || $self->ut_numbern('width')
-    || $self->ut_floatn('range')
+    || $self->ut_floatn('sector_range')
   ;
   return $error if $error;
 
index c3d070e..e74abbf 100755 (executable)
@@ -94,10 +94,18 @@ 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 )
+                   )
+    ";
+  } elsif ( driver_name =~ /^mysql/i ) {
+    push @bugfix, "
+       ALTER TABLE upgrade_journal AUTO_INCREMENT =
+                   ( ( SELECT MAX(upgradenum) FROM upgrade_journal ) + 1 )
+    ";
+  }
 }
 
 if ( $DRY_RUN ) {
index bbfc1a6..02362db 100644 (file)
@@ -2,6 +2,9 @@
     table       => 'tower',
     viewall_dir => 'browse',
     process_o2m => { 'table'  => 'tower_sector',
-                     'fields' => [qw( sectorname ip_addr height freq_mhz direction width range )],
+                     'fields' => [qw(
+                       sectorname ip_addr height freq_mhz direction width
+                       sector_range
+                     )],
                    },
 &>
index 00c9add..fa3838d 100644 (file)
 my $m2_error_callback = sub { # reconstruct the list
   my ($cgi, $object) = @_;
 
-  my @fields = qw( sectorname ip_addr height freq_mhz direction width range );
+  my @fields = qw(
+    sectorname ip_addr height freq_mhz direction width sector_range
+  );
+
   map {
     my $k = $_;
     new FS::tower_sector {
index 406895e..151d3ba 100644 (file)
@@ -51,13 +51,13 @@ if ( $curr_value ) {
 my %size = ( 'title' => 12 );
 
 tie my %label, 'Tie::IxHash',
-  'sectorname' => 'Name',
-  'ip_addr'    => 'IP Address',
-  'height'     => 'Height',
-  'freq_mhz'   => 'Freq. (MHz)',
-  'direction'  => 'Direction', # or a button to set these to 0 for omni
-  'width'      => 'Width',     #
-  'range'      => 'Range',
+  'sectorname'   => 'Name',
+  'ip_addr'      => 'IP Address',
+  'height'       => 'Height',
+  'freq_mhz'     => 'Freq. (MHz)',
+  'direction'    => 'Direction', # or a button to set these to 0 for omni
+  'width'        => 'Width',     #
+  'sector_range' => 'Range',
 ;
 
 my @fields = keys %label;