|
Lines 22-32
if( CheckVersion( $DBversion ) ) {
Link Here
|
| 22 |
SET borrowers.guarantorid = NULL WHERE guarantor.borrowernumber IS NULL; |
22 |
SET borrowers.guarantorid = NULL WHERE guarantor.borrowernumber IS NULL; |
| 23 |
}); |
23 |
}); |
| 24 |
|
24 |
|
|
|
25 |
# Bad data handling: guarantorid IS NOT NULL AND relationship IS NULL |
| 26 |
$dbh->do(q{ |
| 27 |
UPDATE borrowers |
| 28 |
SET relationship = '_bad_data' |
| 29 |
WHERE guarantorid IS NOT NULL AND |
| 30 |
relationship IS NULL |
| 31 |
}); |
| 32 |
|
| 25 |
$dbh->do(q{ |
33 |
$dbh->do(q{ |
| 26 |
INSERT INTO borrower_relationships ( guarantor_id, guarantee_id, relationship ) |
34 |
INSERT INTO borrower_relationships ( guarantor_id, guarantee_id, relationship ) |
| 27 |
SELECT guarantorid, borrowernumber, relationship FROM borrowers WHERE guarantorid IS NOT NULL; |
35 |
SELECT guarantorid, borrowernumber, relationship FROM borrowers WHERE guarantorid IS NOT NULL; |
| 28 |
}); |
36 |
}); |
| 29 |
|
37 |
|
|
|
38 |
# Clean migrated guarantor data |
| 39 |
$dbh->do(q{ |
| 40 |
UPDATE borrowers |
| 41 |
SET contactname=NULL, |
| 42 |
contactfirstname=NULL, |
| 43 |
relationship=NULL |
| 44 |
WHERE guarantorid IS NOT NULL |
| 45 |
}); |
| 30 |
} |
46 |
} |
| 31 |
|
47 |
|
| 32 |
if( column_exists( 'borrowers', 'guarantorid' ) ) { |
48 |
if( column_exists( 'borrowers', 'guarantorid' ) ) { |
| 33 |
- |
|
|