Forum OpenACS Development: reference at acs_object_context_index

I created a script to remove a package that works properly when there is no items inserted on its datamodel.
However, after the second item inserted i tried to remove the package and i get the error bellow.

Transaction aborted: Database operation "0or1row" failed
(exception ERROR, "ERRO: update or delete on "acs_objects" violate foreign key constraint "acs_obj_context_idx_anc_id_fk" on "acs_object_context_index"
DETAIL: Key (object_id)=(806) still is referenced on table "acs_object_context_index".
CONTEXT: comando SQL "delete from acs_objects where object_id = 806"
PL/pgSQL function "acs_object__delete" line 45 at execute statement
comando SQL "SELECT acs_object__delete ( $1 )"
PL/pgSQL function "apm_package__delete" line 31 at perform
")

How do i removed the reference from the index acs_object_context_index

ps. In the script I am using plsql functions to do the package remotion (i.e. acs_object__delete and etc)

Collapse
Posted by Iuri Sampaio on
So far i figured out what were the data still referenced

There were records in the table acs_objects that have in their acs_objects.context_id the object_id of the package i wanted to uninstall.

That is why i got the constraint error.

I looked at their acs_objects.object_type and their values were "cr_item_child_rel" which took me to look at table cr_child_rels.

Then i wrote the query
DELETE FROM cr_child_rels WHERE parent_id = video_object_id;

After that i removed the remaining two records from acs_objects

DELETE FROM acs_objects WHERE context_id = video_object_id;

and Voila! I was able to uninstall my package.

Now, i wonder why these "cr_item_child_rel" records were not removed from acs_objects when i used plpsql functions properly to delete references from cr_items, cr_revisions as well as acs_objects.

Furthermore, I haven't found any plpsql function that treats the data and its references from the table cr_child_rels.

does anyone have a clue what i am talking about? 😊

cheers,