[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Question about what to do on duplicated parts keys



I'd sent this in to the list, but still haven't seen it post, I might have 
accidentally sent it to announce list...

I'm running an update from SL, and have gotten past the customers dup key 
problems as seen in 
http://www.mail-archive.com/..hidden../msg01216.html

This installation seems to have duplicated parts keys as well.  I tried to do 
the following:

BEGIN;
LOCK parts IN EXCLUSIVE MODE;
ALTER TABLE parts ADD COLUMN new_id INT;
UPDATE parts SET new_id = nextval('id');
UPDATE assembly SET parts_id = (select new_id FROM parts WHERE
parts.id = parts_id);
UPDATE inventory SET parts_id = (select new_id FROM parts where
parts.id = parts_id);
UPDATE invoice SET parts_id = (select new_id FROM parts where
parts.id = parts_id);
UPDATE jcitems SET parts_id = (select new_id FROM parts where
parts.id = parts_id);
UPDATE makemodel SET parts_id = (select new_id FROM parts where
parts.id = parts_id);
UPDATE orderitems SET parts_id = (select new_id FROM parts where
parts.id = parts_id);
UPDATE partscustomer SET parts_id = (select new_id FROM parts where
parts.id = parts_id);
UPDATE partstax SET parts_id = (select new_id FROM parts where
parts.id = parts_id);
UPDATE partsvendor SET parts_id = (select new_id FROM parts where
parts.id = parts_id);
UPDATE project SET parts_id = (select new_id FROM parts where
parts.id = parts_id);
UPDATE parts SET id = new_id;
ALTER TABLE parts DROP COLUMN new_id;
COMMIT;

Which let the Pg-upgrade-2.6.17-2.6.18.sql script run, but after doing so, I 
end up with NULL's in some places in the partstax table, so that it is not 
possible to run:

ALTER TABLE partstax ADD PRIMARY KEY (parts_id, chart_id);

From the Pg-upgrade-2.6.18-2.6.19.sql script.

Any idea about how I can deal with this parts problem... I can send some 
relevant dumps and so on...  I'm guessing my stab at fixing the dup parts 
ID's isn't quite right.

Thanks,
Leah
-- 
Leah Kubik : d416-585-9971x692 : d416-703-5977 : m416-559-6511
Frauerpower! Co. : www.frauerpower.com : Toronto, ON Canada
MSN: ..hidden.. | AIM: frauerpower | Yahoo: h3inous
F9B6 FEFE 080B 8299 D7EA  1270 005C EC73 47C9 B7A6