summaryrefslogtreecommitdiff
path: root/FS/FS
diff options
context:
space:
mode:
authorivan <ivan>2010-03-27 03:43:59 +0000
committerivan <ivan>2010-03-27 03:43:59 +0000
commitc8caa293a6b25b86b05b78faadd08da16f3f9614 (patch)
treeadd3a217a6d0ea8eb36e6c94a9f5c387b586290a /FS/FS
parentacb1f7d01eb5300547fd8f105fe43ee88dd65e00 (diff)
these are now supported in supported in DBIx-DBSchema and friends
Diffstat (limited to 'FS/FS')
-rw-r--r--FS/FS/reason.pm54
-rw-r--r--FS/FS/tax_rate.pm107
2 files changed, 2 insertions, 159 deletions
diff --git a/FS/FS/reason.pm b/FS/FS/reason.pm
index 5311ec5..377da49 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 463fc08..9920aa6 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