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

Re: Question about what to do on duplicated parts keys



On Thursday 28 June 2007 15:56, Leah Kubik wrote:
> 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
>
> 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.

So in IRC it was decide could probably just avoid these lines from 
Pg-upgrade-2.6.17-2.6.18.sql :

--INSERT INTO transactions (id, table_name) SELECT id, 'parts' FROM parts;

--CREATE RULE parts_id_track_i AS ON insert TO parts
--DO INSERT INTO transactions (id, table_name) VALUES (new.id, 'parts');

--CREATE RULE parts_id_track_u AS ON update TO parts
--DO UPDATE transactions SET id = new.id WHERE id = old.id;

This gets us past that set of db updates, but now have a problem with 

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

If I don't set this primary key, I get stuck at the next lines:

ALTER TABLE partstax ADD FOREIGN KEY (chart_id) REFERENCES chart (id);
ALTER TABLE partstax ADD FOREIGN KEY (parts_id) REFERENCES parts (id);

ERROR:  insert or update on table "partstax" violates foreign key 
constraint "partstax_parts_id_fkey"
DETAIL:  Key (parts_id)=(14590) is not present in table "parts".

Any idears what is best thing to do about this?

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