File: /www/exchange2/sql/custom/TK23971-Delete-test-Originators-Credebtors.sql
/* ---------------------- NEW TO CHECK 2021-09-21 ---------------------- */
/* #1 */
/* TK25384 - Delete unused/incorrect/test Credebtor records */
/* delete dead debtor relations */
DELETE FROM debtor_relation WHERE relation_id IN(538, 774, 776, 793, 905, 979, 1302);
DELETE FROM debtors_detail WHERE debtor_id IN(6766,6767,6768,6769,6770,6771,7193,7194,7213,7214);
DELETE FROM debtor_relation WHERE debtor_id IN(6766,6767,6768,6769,6770,6771,7193,7194,7213,7214);
DELETE FROM debtor_contacts WHERE debtor_id IN(6766,6767,6768,6769,6770,6771,7193,7194,7213,7214);
DELETE FROM address_details WHERE address_id IN (41164,41165,41166,41167,41168,41169,41170,41171,41172,41173,41174,41175,41176,41177,41178,41179,41180,41181,43631,43632,43633,43634,43635,43636,43761,43762,43763,43764,43765,43766);
/* #2 */
/*Credebtors to Delete
SID LID MSID MLID
6115 20190206006115 6815 20190206006815
6209 20190527006209 6892 20190527006892
6224 20190611006224 6907 20190611006907
6401 20190828006401 7072 20190828007072
6403 20190828006403 7074 20190828007074
6405 20190829006405 7074 20190828007074
6411 20190903006411 7080 20190903007080
6412 20190903006412 6817 20190211006817
6413 20190903006413 6817 20190211006817
6414 20190903006414 6817 20190211006817
6415 20190903006415 6817 20190211006817
6416 20190903006416 6817 20190211006817
6417 20190903006417 6817 20190211006817
Originators to Delete
SID LID
1799 12102001799
1800 12102001800
1803 12103001803
1806 12103001806
1845 12106001845
1855 12106001855*/
/* #3 */
/*-- delete Originators from Exchange 2.0
12102001799 44228
12102001800 RT Test 18 feb test 2021
12103001803 RT test March 2
12103001806 RT Test March 5 2021
11307000041
12001001683
20130711000055
20200130006639*/
/* #4 */
/*organisation_id: 1759, 1758
user_id: 1892, 1891
organisation_reference_id: 12010001759, 12010001758
organisation_address_id: 44476, 44469
organisation_regoffice_id: 44476, 44469*/
/* #5 */
/* Unable to remove organisation from CRM: 0010Y00001as3DaQAI
Delete Debtor: 20190828006401 from Exchange
Delete Debtor: 20190829006405 from Exchange */
/* ---------------------- NEW TO CHECK 2021-09-21 ---------------------- */
/* TK23971 - Delete test Credebtor records */
DELETE FROM debtors_detail WHERE debtor_id IN(6766,6767,6768,6769,6770,6771,7193,7194,7213,7214);
DELETE FROM debtor_relation WHERE debtor_id IN(6766,6767,6768,6769,6770,6771,7193,7194,7213,7214);
DELETE FROM debtor_contacts WHERE debtor_id IN(6766,6767,6768,6769,6770,6771,7193,7194,7213,7214);
DELETE FROM address_details WHERE address_id IN (41164,41165,41166,41167,41168,41169,41170,41171,41172,41173,41174,41175,41176,41177,41178,41179,41180,41181,43631,43632,43633,43634,43635,43636,43761,43762,43763,43764,43765,43766);
/* get relevant relation IDs from DB */
SELECT organisation_id, user_id, organisation_address_id, organisation_regoffice_id, mail_address_id, billing_address_id FROM organisation_details WHERE organisation_id IN(1414,1415,1419,1446,1476,1537,1545,1546,1551,1569,1570,1578,1580,1584,1589,1593,1594,1596,1607,1608,1628,1629,1632,1638,1667,1691,1699,1707);
SELECT temp_reg_id FROM contact_details WHERE organisation_id IN(1414,1415,1419,1446,1476,1537,1545,1546,1551,1569,1570,1578,1580,1584,1589,1593,1594,1596,1607,1608,1628,1629,1632,1638,1667,1691,1699,1707);
/* Delete test Originator records */
/* taken from organisation_details table */
DELETE FROM address_details WHERE address_id IN(37082,37082,37084,37083,37095,37095,37097,37096,37133,37133,37135,37134,37483,37483,37485,37484,37726,37726,37728,37727,38300,38300,38302,38301,38357,38357,38359,38358,38401,38401,38403,38402,38431,38431,38433,38432,38905,38905,38907,38906,38916,38916,38918,38917,39091,39091,39093,39092,39105,39105,39107,39106,39161,39161,39163,39162,39247,39247,39249,39248,39300,39300,39302,39301,39314,39314,39316,39315,39364,39364,39366,39365,39498,39498,39500,39499,39509,39509,39511,39510,39794,39794,39796,39795,39805,39805,39807,39806,39830,39830,39832,39831,39960,39960,39962,39961,40405,40405,40407,40406,41153,41153,41155,41154,43622,43622,43624,43623,43750,43750,43752,43751);
/* taken from contact_details table */
DELETE FROM temp_registration WHERE temp_reg_id IN(1629,1630,1635,1661,1691,1752,1763,1764,1767,1784,1785,1793,1795,1799,1804,1808,1809,1811,1822,1823,1843,1844,1847,1853,1884,1907,1916,1924);
DELETE FROM contact_details WHERE temp_reg_id IN(1629,1630,1635,1661,1691,1752,1763,1764,1767,1784,1785,1793,1795,1799,1804,1808,1809,1811,1822,1823,1843,1844,1847,1853,1884,1907,1916,1924);
/* taken from organisation_details table */
DELETE FROM user_login WHERE user_id IN(1548,1549,1553,1580,1610,1670,1678,1679,1684,1702,1703,1711,1713,1717,1722,1726,1727,1729,1740,1741,1761,1762,1765,1771,1800,1824,1832,1840);
DELETE FROM temp_organisation_details WHERE user_id IN(1548,1549,1553,1580,1610,1670,1678,1679,1684,1702,1703,1711,1713,1717,1722,1726,1727,1729,1740,1741,1761,1762,1765,1771,1800,1824,1832,1840);
/* taken from organisation_details table */
DELETE FROM organisation_details WHERE organisation_id IN(1414,1415,1419,1446,1476,1537,1545,1546,1551,1569,1570,1578,1580,1584,1589,1593,1594,1596,1607,1608,1628,1629,1632,1638,1667,1691,1699,1707);
DELETE FROM contact_details WHERE organisation_id IN(1414,1415,1419,1446,1476,1537,1545,1546,1551,1569,1570,1578,1580,1584,1589,1593,1594,1596,1607,1608,1628,1629,1632,1638,1667,1691,1699,1707);
DELETE FROM organisation_bank_details WHERE organisation_id IN(1414,1415,1419,1446,1476,1537,1545,1546,1551,1569,1570,1578,1580,1584,1589,1593,1594,1596,1607,1608,1628,1629,1632,1638,1667,1691,1699,1707);
DELETE FROM organisation_currency WHERE organisation_id IN(1414,1415,1419,1446,1476,1537,1545,1546,1551,1569,1570,1578,1580,1584,1589,1593,1594,1596,1607,1608,1628,1629,1632,1638,1667,1691,1699,1707);
DELETE FROM organisation_currencies WHERE organisation_id IN(1414,1415,1419,1446,1476,1537,1545,1546,1551,1569,1570,1578,1580,1584,1589,1593,1594,1596,1607,1608,1628,1629,1632,1638,1667,1691,1699,1707);
DELETE FROM directorate WHERE organization_id IN(1414,1415,1419,1446,1476,1537,1545,1546,1551,1569,1570,1578,1580,1584,1589,1593,1594,1596,1607,1608,1628,1629,1632,1638,1667,1691,1699,1707);