fix contract_end bug, RT#10319
authormark <mark>
Fri, 22 Oct 2010 22:38:37 +0000 (22:38 +0000)
committermark <mark>
Fri, 22 Oct 2010 22:38:37 +0000 (22:38 +0000)
bin/fix-contract_end [new file with mode: 0755]

diff --git a/bin/fix-contract_end b/bin/fix-contract_end
new file mode 100755 (executable)
index 0000000..6458722
--- /dev/null
@@ -0,0 +1,24 @@
+#!/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;