diff options
Diffstat (limited to 'FS')
| -rw-r--r-- | FS/FS/reason.pm | 54 | ||||
| -rw-r--r-- | FS/FS/tax_rate.pm | 107 | 
2 files changed, 2 insertions, 159 deletions
diff --git a/FS/FS/reason.pm b/FS/FS/reason.pm index 5311ec5aa..377da4985 100644 --- a/FS/FS/reason.pm +++ b/FS/FS/reason.pm @@ -114,60 +114,6 @@ sub reasontype {    qsearchs( 'reason_type', { 'typenum' => shift->reason_type } );  } -# _upgrade_data -# -# Used by FS::Upgrade to migrate to a new database. -# -# - -sub _upgrade_data {  # class method -  my ($self, %opts) = @_; -  my $dbh = dbh; - -  warn "$me upgrading $self\n" if $DEBUG; - -  my $column = dbdef->table($self->table)->column('reason'); -  unless ($column->type eq 'text') { # assume history matches main table - -    # ideally this would be supported in DBIx-DBSchema and friends -    warn "$me Shifting reason column to type 'text'\n" if $DEBUG; -    foreach my $table ( $self->table, 'h_'. $self->table ) { -      my @sql = (); - -      $column = dbdef->table($self->table)->column('reason'); -      my $columndef = $column->line($dbh); -      $columndef =~ s/varchar\(\d+\)/text/i; - -      if ( $dbh->{Driver}->{Name} eq 'Pg' ) { - -        my $notnull = $columndef =~ s/not null//i; -        push @sql,"ALTER TABLE $table RENAME reason TO freeside_upgrade_reason"; -        push @sql,"ALTER TABLE $table ADD $columndef"; -        push @sql,"UPDATE $table SET reason = freeside_upgrade_reason"; -        push @sql,"ALTER TABLE $table ALTER reason SET NOT NULL" -          if $notnull; -        push @sql,"ALTER TABLE $table DROP freeside_upgrade_reason"; - -      } elsif ( $dbh->{Driver}->{Name} =~ /^mysql/i ){ - -        #crap, this isn't working -        #push @sql,"ALTER TABLE $table MODIFY reason ". $column->line($dbh); -        warn "WARNING: reason table upgrade not yet supported for mysql, sorry"; - -      } else { -        die "watchu talkin' 'bout, Willis? (unsupported database type)"; -      } - -      foreach (@sql) { -        my $sth = $dbh->prepare($_) or die $dbh->errstr; -        $sth->execute or die $sth->errstr; -      } -    } -  } - - ''; - -}  =back  =head1 BUGS diff --git a/FS/FS/tax_rate.pm b/FS/FS/tax_rate.pm index 463fc0876..9920aa650 100644 --- a/FS/FS/tax_rate.pm +++ b/FS/FS/tax_rate.pm @@ -502,7 +502,9 @@ given customer (see L<FS::cust_main>)  =cut +    #hot  sub tax_on_tax { +       #akshun    my $self = shift;    my $cust_main = shift; @@ -1755,111 +1757,6 @@ sub browse_queries {    return ($query, "SELECT COUNT(*) FROM tax_rate $extra_sql");  } -# _upgrade_data -# -# Used by FS::Upgrade to migrate to a new database. -# -# - -sub _upgrade_data {  # class method -  my ($self, %opts) = @_; -  my $dbh = dbh; - -  warn "$me upgrading $self\n" if $DEBUG; - -  my @column = qw ( tax excessrate usetax useexcessrate fee excessfee -                    feebase feemax ); - -  if ( $dbh->{Driver}->{Name} eq 'Pg' ) { - -    eval "use DBI::Const::GetInfoType;"; -    die $@ if $@; - -    my $major_version = 0; -    $dbh->get_info( $GetInfoType{SQL_DBMS_VER} ) =~ /^(\d{2})/ -      && ( $major_version = sprintf("%d", $1) ); - -    if ( $major_version > 7 ) { - -      # ideally this would be supported in DBIx-DBSchema and friends - -      foreach my $column ( @column ) { -        my $columndef = dbdef->table($self->table)->column($column); -        unless ($columndef->type eq 'numeric') { - -          warn "updating tax_rate column $column to numeric\n" if $DEBUG; -          my $sql = "ALTER TABLE tax_rate ALTER $column TYPE numeric(14,8)"; -          my $sth = $dbh->prepare($sql) or die $dbh->errstr; -          $sth->execute or die $sth->errstr; - -          warn "updating h_tax_rate column $column to numeric\n" if $DEBUG; -          $sql = "ALTER TABLE h_tax_rate ALTER $column TYPE numeric(14,8)"; -          $sth = $dbh->prepare($sql) or die $dbh->errstr; -          $sth->execute or die $sth->errstr; - -        } -      } - -    } elsif ( $dbh->{pg_server_version} =~ /^704/ ) { - -      # ideally this would be supported in DBIx-DBSchema and friends - -      foreach my $column ( @column ) { -        my $columndef = dbdef->table($self->table)->column($column); -        unless ($columndef->type eq 'numeric') { - -          warn "updating tax_rate column $column to numeric\n" if $DEBUG; - -          foreach my $table ( qw( tax_rate h_tax_rate ) ) { - -            my $sql = "ALTER TABLE $table RENAME $column TO old_$column"; -            my $sth = $dbh->prepare($sql) or die $dbh->errstr; -            $sth->execute or die $sth->errstr; - -            my $def = dbdef->table($table)->column($column); -            $def->type('numeric'); -            $def->length('14,8');  -            my $null = $def->null; -            $def->null('NULL'); - -            $sql = "ALTER TABLE $table ADD COLUMN ". $def->line($dbh); -            $sth = $dbh->prepare($sql) or die $dbh->errstr; -            $sth->execute or die $sth->errstr; - -            $sql = "UPDATE $table SET $column = CAST( old_$column AS numeric )"; -            $sth = $dbh->prepare($sql) or die $dbh->errstr; -            $sth->execute or die $sth->errstr; - -            unless ( $null eq 'NULL' ) { -              $sql = "ALTER TABLE $table ALTER $column SET NOT NULL"; -              $sth = $dbh->prepare($sql) or die $dbh->errstr; -              $sth->execute or die $sth->errstr; -            } - -            $sql = "ALTER TABLE $table DROP old_$column"; -            $sth = $dbh->prepare($sql) or die $dbh->errstr; -            $sth->execute or die $sth->errstr; - -          } -        } -      } - -    } else { - -      warn "WARNING: tax_rate table upgrade unsupported for this Pg version\n"; - -    } - -  } else { - -    warn "WARNING: tax_rate table upgrade only supported for Pg 8+\n"; - -  } - -  ''; - -} -  =back  =head1 BUGS  | 
