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

Re: First upgrade attempt from 1.2.21 -> 1.3.0RC4 == Fail





On Fri, 7 Oct 2011, ..hidden.. wrote:


This time making it to

INSERT INTO audittrail(trans_id, tablename, reference, formname, action,
            transdate, person_id, entry_id)
     SELECT trans_id, tablename, reference, formname, action,
            transdate, p.id, entry_id
       FROM lsmb12.audittrail a
       JOIN lsmb12.employee e ON a.employee_id = e.id
       JOIN person p on e.entity_id = p.entity_id;

psql:sql/upgrade/1.2-1.3-manual.sql:582: ERROR:  insert or update on table
"audittrail" violates foreign key constraint "audittrail_person_id_fkey"
DETAIL:  Key (person_id)=(1) is not present in table "person".


It looks like either the contraint

  "audittrail_person_id_fkey" FOREIGN KEY (person_id) REFERENCES person(entity_id)

should be

"audittrail_person_id_fkey" FOREIGN KEY (person_id) REFERENCES person(id)

OR

the query should be

INSERT INTO audittrail(trans_id, tablename, reference, formname, action,
            transdate, person_id, entry_id)
     SELECT trans_id, tablename, reference, formname, action,
            transdate, p.entity_id, entry_id
       FROM lsmb12.audittrail a
       JOIN lsmb12.employee e ON a.employee_id = e.id
       JOIN person p on e.entity_id = p.entity_id;



I'm going to change the query and see what happens to the clone DB.


and it runs to completion!


...

UPDATE defaults SET value = '1.2.99' WHERE setting_key = 'version';
UPDATE 1
COMMIT;
COMMIT
--TODO:  Translation migratiion.  Partsgroups?
-- TODO:  User/password Migration