[freeside-commits] freeside/bin fix-contract_end,NONE,1.1

Mark Wells mark at wavetail.420.am
Fri Oct 22 15:38:39 PDT 2010


Update of /home/cvs/cvsroot/freeside/bin
In directory wavetail.420.am:/tmp/cvs-serv21895

Added Files:
	fix-contract_end 
Log Message:
fix contract_end bug, RT#10319

--- NEW FILE: fix-contract_end ---
#!/usr/bin/perl

use strict;
use warnings;
use FS::Record;
use FS::UID qw(adminsuidsetup dbh driver_name);

# Fix bad values in some contract_end fields resulting from a short-lived bug

my $dbh = adminsuidsetup(shift) or die "Usage: fix-contract_end username\n";
local $FS::UID::AutoCommit = 0;

my @updates = (
  q!UPDATE cust_pkg SET contract_end = NULL WHERE contract_end = -1!,
  q!UPDATE part_pkg_option SET optionvalue = NULL WHERE optionname = 'contract_end_months' AND optionvalue = '(none)'!,
);

foreach my $sql (@updates) {
  print "$sql\n";
  my $rows = $dbh->do($sql);
  print "$rows rows.\n";
  die $dbh->errstr if $dbh->errstr;
}
$dbh->commit or die $dbh->errstr;



More information about the freeside-commits mailing list