diff options
author | ivan <ivan> | 2001-09-06 20:42:00 +0000 |
---|---|---|
committer | ivan <ivan> | 2001-09-06 20:42:00 +0000 |
commit | 57d69d5c1f98f778a0df82795ce21ee7bd21042a (patch) | |
tree | 63f890cf25311b66c712933c84f64e43718039cd /bin | |
parent | db1b6ebfe35aba1f4d2580b13a0a74ac317784ba (diff) |
finally fix part_svc!!!
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/fs-migrate-part_svc | 40 | ||||
-rwxr-xr-x | bin/fs-migrate-payref | 7 | ||||
-rwxr-xr-x | bin/fs-radius-add-check | 4 | ||||
-rwxr-xr-x | bin/fs-radius-add-reply | 4 | ||||
-rwxr-xr-x | bin/fs-setup | 67 |
5 files changed, 88 insertions, 34 deletions
diff --git a/bin/fs-migrate-part_svc b/bin/fs-migrate-part_svc new file mode 100755 index 000000000..96332f72a --- /dev/null +++ b/bin/fs-migrate-part_svc @@ -0,0 +1,40 @@ +#!/usr/bin/perl + +use strict; +use FS::UID qw(adminsuidsetup); +use FS::Record qw(qsearchs); +use FS::part_svc + +my $user = shift or die &usage; +my $dbh = adminsuidsetup $user; + +my $oldAutoCommit = $FS::UID::AutoCommit; +local $FS::UID::AutoCommit = 0 + +foreach my $part_svc ( qsearch('part_svc', {} ) ) { + foreach my $field ( + grep { defined($part_svc->getfield($part_svc->svcdb.'__'.$field.'_flag') ) } + fields($self->svcdb) + ) { + my $flag = $self->getfield($part_svc->svcdb.'__'.$field.'_flag'); + if ( uc($flag) =~ /^([DF])$/ ) { + $part_svc_column->setfield('columnflag', $1); + $part_svc_column->setfield('columnvalue', + $self->getfield($part_svc->svcdb.'__'.$field) + ); + $error = $part_svc_column->insert; + } else { + $error = $part_svc_column->delete; + } + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + die $error; + } + + } +} + +sub usage { + die "Usage:\n fs-migrate-part_svc user\n"; +} + diff --git a/bin/fs-migrate-payref b/bin/fs-migrate-payref index f1513112b..158419706 100755 --- a/bin/fs-migrate-payref +++ b/bin/fs-migrate-payref @@ -9,9 +9,6 @@ use FS::cust_refund; my $user = shift or die &usage; my $dbh = adminsuidsetup $user; -#local $FS::UID::AutoCommit = 0; #quelle hack, in this case -# $FS::UID::AutoCommit = 0; #quelle hack, in this case - # apply payments to invoices foreach my $cust_pay ( qsearch('cust_pay', {} ) ) { @@ -28,3 +25,7 @@ foreach my $cust_refund ( qsearch('cust_refund') ) { # ? apply credits to invoices +sub usage { + die "Usage:\n fs-migrate-payref user\n"; +} + diff --git a/bin/fs-radius-add-check b/bin/fs-radius-add-check index 92523eb95..fadba0165 100755 --- a/bin/fs-radius-add-check +++ b/bin/fs-radius-add-check @@ -35,8 +35,8 @@ my($char_d) = 80; #default maxlength for text fields foreach my $attribute ( @attributes ) { foreach my $statement ( "ALTER TABLE svc_acct ADD rc_$attribute varchar($char_d) NULL", - "ALTER TABLE part_svc ADD svc_acct__rc_$attribute varchar($char_d) NULL;", - "ALTER TABLE part_svc ADD svc_acct__rc_${attribute}_flag char(1) NULL;", +# "ALTER TABLE part_svc ADD svc_acct__rc_$attribute varchar($char_d) NULL;", +# "ALTER TABLE part_svc ADD svc_acct__rc_${attribute}_flag char(1) NULL;", ) { $dbh->do( $statement ) or warn "Error executing $statement: ". $dbh->errstr; } } diff --git a/bin/fs-radius-add-reply b/bin/fs-radius-add-reply index 7938feac6..997a8eac7 100755 --- a/bin/fs-radius-add-reply +++ b/bin/fs-radius-add-reply @@ -35,8 +35,8 @@ my($char_d) = 80; #default maxlength for text fields foreach my $attribute ( @attributes ) { foreach my $statement ( "ALTER TABLE svc_acct ADD radius_$attribute varchar($char_d) NULL", - "ALTER TABLE part_svc ADD svc_acct__radius_$attribute varchar($char_d) NULL;", - "ALTER TABLE part_svc ADD svc_acct__radius_${attribute}_flag char(1) NULL;", +# "ALTER TABLE part_svc ADD svc_acct__radius_$attribute varchar($char_d) NULL;", +# "ALTER TABLE part_svc ADD svc_acct__radius_${attribute}_flag char(1) NULL;", ) { $dbh->do( $statement ) or warn "Error executing $statement: ". $dbh->errstr; } } diff --git a/bin/fs-setup b/bin/fs-setup index 5dc666a1e..53d96f692 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.53 2001-09-04 11:15:58 ivan Exp $ +# $Id: fs-setup,v 1.54 2001-09-06 20:41:59 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -122,32 +122,32 @@ foreach $attribute (@check_attributes) { )); } -#make part_svc table (but now as object) - -my($part_svc)=$dbdef->table('part_svc'); - -#because of svc_acct_pop -#foreach (grep /^svc_/, $dbdef->tables) { -#foreach (qw(svc_acct svc_acct_sm svc_charge svc_domain svc_wo)) { -foreach (qw(svc_acct svc_domain svc_forward svc_www)) { - my($table)=$dbdef->table($_); - my($col); - foreach $col ( $table->columns ) { - next if $col =~ /^svcnum$/; - $part_svc->addcolumn( new DBIx::DBSchema::Column ( - $table->name. '__' . $table->column($col)->name, - 'varchar', #$table->column($col)->type, - 'NULL', - $char_d, #$table->column($col)->length, - )); - $part_svc->addcolumn ( new DBIx::DBSchema::Column ( - $table->name. '__'. $table->column($col)->name . "_flag", - 'char', - 'NULL', - 1, - )); - } -} +##make part_svc table (but now as object) +# +#my($part_svc)=$dbdef->table('part_svc'); +# +##because of svc_acct_pop +##foreach (grep /^svc_/, $dbdef->tables) { +##foreach (qw(svc_acct svc_acct_sm svc_charge svc_domain svc_wo)) { +#foreach (qw(svc_acct svc_domain svc_forward svc_www)) { +# my($table)=$dbdef->table($_); +# my($col); +# foreach $col ( $table->columns ) { +# next if $col =~ /^svcnum$/; +# $part_svc->addcolumn( new DBIx::DBSchema::Column ( +# $table->name. '__' . $table->column($col)->name, +# 'varchar', #$table->column($col)->type, +# 'NULL', +# $char_d, #$table->column($col)->length, +# )); +# $part_svc->addcolumn ( new DBIx::DBSchema::Column ( +# $table->name. '__'. $table->column($col)->name . "_flag", +# 'char', +# 'NULL', +# 1, +# )); +# } +#} #important $dbdef->save($dbdef_file); @@ -580,6 +580,19 @@ sub tables_hash_hack { 'index' => [ [] ], }, + 'part_svc_column' => { + 'columns' => [ + 'columnnum', 'int', '', '', + 'svcpart', 'int', '', '', + 'columnname', 'varchar', '', 64, + 'columnvalue', 'varchar', 'NULL', $char_d, + 'columnflag', 'char', 'NULL', 1, + ], + 'primary_key' => 'columnnum', + 'unique' => [ [ 'svcpart', 'columnname' ] ], + 'index' => [ [ 'svcpart' ] ], + } + #(this should be renamed to part_pop) 'svc_acct_pop' => { 'columns' => [ |