Lines 1-4
Link Here
|
1 |
CREATE TABLE `relationships` ( |
1 |
CREATE TABLE `borrower_relationships` ( |
2 |
id INT(11) NOT NULL AUTO_INCREMENT, |
2 |
id INT(11) NOT NULL AUTO_INCREMENT, |
3 |
guarantor_id INT(11) NULL DEFAULT NULL, |
3 |
guarantor_id INT(11) NULL DEFAULT NULL, |
4 |
guarantee_id INT(11) NOT NULL, |
4 |
guarantee_id INT(11) NOT NULL, |
Lines 12-17
CREATE TABLE `relationships` (
Link Here
|
12 |
|
12 |
|
13 |
UPDATE borrowers LEFT JOIN borrowers guarantor ON ( borrowers.guarantorid = guarantor.borrowernumber ) SET borrowers.guarantorid = NULL WHERE guarantor.borrowernumber IS NULL; |
13 |
UPDATE borrowers LEFT JOIN borrowers guarantor ON ( borrowers.guarantorid = guarantor.borrowernumber ) SET borrowers.guarantorid = NULL WHERE guarantor.borrowernumber IS NULL; |
14 |
|
14 |
|
15 |
INSERT INTO relationships ( guarantor_id, guarantee_id, relationship, surname, firstname ) SELECT guarantorid, borrowernumber, relationship, contactname, contactfirstname FROM borrowers WHERE guarantorid IS NOT NULL OR contactname != ""; |
15 |
INSERT INTO borrower_relationships ( guarantor_id, guarantee_id, relationship, surname, firstname ) SELECT guarantorid, borrowernumber, relationship, contactname, contactfirstname FROM borrowers WHERE guarantorid IS NOT NULL OR contactname != ""; |
16 |
|
16 |
|
17 |
ALTER TABLE borrowers DROP guarantorid, DROP relationship, DROP contactname, DROP contactfirstname, DROP contacttitle; |
17 |
ALTER TABLE borrowers DROP guarantorid, DROP relationship, DROP contactname, DROP contactfirstname, DROP contacttitle; |
|
|
18 |
ALTER TABLE deletedborrowers DROP guarantorid, DROP relationship, DROP contactname, DROP contactfirstname, DROP contacttitle; |
19 |
ALTER TABLE borrowermodification DROP guarantorid, DROP relationship, DROP contactname, DROP contactfirstname, DROP contacttitle; |