Since I'm here talking about upgrades.
The dodgy data I am scripting out is in RA_ShipLines, RA_CreditLines and RA_CreditLineDetails, referencing deleted inventory items. There are just a few, and they're all related to ancient transactions. They were breaking 7.0.42.00880,02385 & 02640.
They can be checked with
- Code: Select all
select * FROM RA_ShipLines where not InventoryID in (select InventoryID from IN_Main);
select * from RA_CreditLines where not InventoryID in (select InventoryID from IN_Main);
select * from RA_CreditLineDetails where not InvID in (select InventoryID from IN_Main);
and deleted with
- Code: Select all
delete FROM RA_ShipLines output deleted.* where not InventoryID in (select InventoryID from IN_Main);
delete from RA_CreditLines output deleted.* where not InventoryID in (select InventoryID from IN_Main);
delete from RA_CreditLineDetails output deleted.* where not InvID in (select InventoryID from IN_Main);
(just 4 records between the 3 tables for me, involving two InventoryIDs)
I previously had problems with upgrade steps 7.0.64.00530, but that's fine now.
My script also drops a bunch of locally-added indexes (some of which I'm putting back afterwards), and drops all statistics and DTA-created indexes (some of which caused trouble in an earlier attempt; I'm not sure if they still do, but in this case, they're so old that they are probably no longer relevant anyway).
We also had a problem with SettingID clashes between CR_, DB_ and IN_ custom settings (because they didn't used to share a table), which I resolved by making the ID's the DisplayOrder prefixed with the CR_, DB_ and _IN. This had the added benefit of making it easier to code plugin logic that used the IDs.
I'll be changing my script to change just one of the 'problem' RE_Main records, so the standard script will still kick in for all the other ones.