summaryrefslogtreecommitdiff
path: root/FS/FS/cust_main.pm
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2012-06-02 00:54:43 -0700
committerIvan Kohler <ivan@freeside.biz>2012-06-02 00:54:43 -0700
commit5d26dfd79434bf28dcafe62a4aa8762a6aa5a379 (patch)
tree1841253e27d7e801ccb044b17ebaac17b4627d18 /FS/FS/cust_main.pm
parent387a6d63bee098b013f8ea3f53a4d349b0c0d928 (diff)
journal expensive parts parts of cust_main upgrade, RT#17629
Diffstat (limited to 'FS/FS/cust_main.pm')
-rw-r--r--FS/FS/cust_main.pm36
1 files changed, 26 insertions, 10 deletions
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 3ef377497..98071dd95 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -72,6 +72,7 @@ use FS::cust_main_note;
use FS::cust_attachment;
use FS::contact;
use FS::Locales;
+use FS::upgrade_journal;
# 1 is mostly method/subroutine entry and options
# 2 traces progress of some operations
@@ -5041,21 +5042,36 @@ sub _upgrade_data { #class method
my @statements = (
'UPDATE h_cust_main SET paycvv = NULL WHERE paycvv IS NOT NULL',
- 'UPDATE cust_main SET signupdate = (SELECT signupdate FROM h_cust_main WHERE signupdate IS NOT NULL AND h_cust_main.custnum = cust_main.custnum ORDER BY historynum DESC LIMIT 1) WHERE signupdate IS NULL',
);
- # fix yyyy-m-dd formatted paydates
- if ( driver_name =~ /^mysql/i ) {
+
+ unless ( FS::upgrade_journal->is_done('cust_main__signupdate') ) {
push @statements,
- "UPDATE cust_main SET paydate = CONCAT( SUBSTRING(paydate FROM 1 FOR 5), '0', SUBSTRING(paydate FROM 6) ) WHERE SUBSTRING(paydate FROM 7 FOR 1) = '-'";
+ 'UPDATE cust_main SET signupdate = (SELECT signupdate FROM h_cust_main WHERE signupdate IS NOT NULL AND h_cust_main.custnum = cust_main.custnum ORDER BY historynum DESC LIMIT 1) WHERE signupdate IS NULL';
+ FS::upgrade_journal->set_done('cust_main__signupdate');
}
- else { # the SQL standard
- push @statements,
- "UPDATE cust_main SET paydate = SUBSTRING(paydate FROM 1 FOR 5) || '0' || SUBSTRING(paydate FROM 6) WHERE SUBSTRING(paydate FROM 7 FOR 1) = '-'";
+
+ unless ( FS::upgrade_journal->is_done('cust_main__paydate') ) {
+
+ # fix yyyy-m-dd formatted paydates
+ if ( driver_name =~ /^mysql/i ) {
+ push @statements,
+ "UPDATE cust_main SET paydate = CONCAT( SUBSTRING(paydate FROM 1 FOR 5), '0', SUBSTRING(paydate FROM 6) ) WHERE SUBSTRING(paydate FROM 7 FOR 1) = '-'";
+ } else { # the SQL standard
+ push @statements,
+ "UPDATE cust_main SET paydate = SUBSTRING(paydate FROM 1 FOR 5) || '0' || SUBSTRING(paydate FROM 6) WHERE SUBSTRING(paydate FROM 7 FOR 1) = '-'";
+ }
+ FS::upgrade_journal->set_done('cust_main__paydate');
}
- push @statements, #fix the weird BILL with a cc# in payinfo problem
- #DCRD to be safe
- "UPDATE cust_main SET payby = 'DCRD' WHERE payby = 'BILL' and length(payinfo) = 16 and payinfo ". regexp_sql. q( '^[0-9]*$' );
+ unless ( FS::upgrade_journal->is_done('cust_main__payinfo') ) {
+
+ push @statements, #fix the weird BILL with a cc# in payinfo problem
+ #DCRD to be safe
+ "UPDATE cust_main SET payby = 'DCRD' WHERE payby = 'BILL' and length(payinfo) = 16 and payinfo ". regexp_sql. q( '^[0-9]*$' );
+
+ FS::upgrade_journal->set_done('cust_main__payinfo');
+
+ }
my $t = time;
foreach my $sql ( @statements ) {