Forum OpenACS Q&A: null tree_sortkey on upgrading acs-kernel

We are attempting to upgrade a very old OpenACS installation from 5.1.2 to 5.7.0. On upgrading acs-kernel, we get the following error at the end of the upgrade:
    Loading data model /var/lib/aolserver/caryoil/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.7.0d10-5.7.0d11.sql...

        CREATE FUNCTION
        CREATE FUNCTION
        CREATE FUNCTION
        CREATE FUNCTION

Failed to install Kernel, version 5.7.0. The following error was generated:

    Database operation "0or1row" failed (exception ERROR, "ERROR: null value in column "tree_sortkey" violates not-null
 constraint CONTEXT: SQL statement "insert into acs_objects 
(object_id, object_type, title, package_id, context_id, creation_date, creation_user, creation_ip, security_inherit_p) 
values ( $1 , $2 , $3 , $4 , $5 , $6 , $7 , $8 , $9 )" PL/pgSQL function "acs_object__new" line 39 at SQL 
statement PL/pgSQL function "apm_package_version__new" line 25 at assignment
Does anyone have suggestions on how to move past this? I have modified the upgrade scripts slightly, but only to comment out dropping constraints, triggers, and tables which do not yet exist. Thanks in advance for any pointers. Kind regards, Justis
Collapse
Posted by Victor Guerra on
Hi Justis,

actually there is a trigger on the acs_objects table ( acs_objects_insert_tr ) which executes before inserting, that trigger takes care of calculating the tree_sortkey. Are you probably dropping that trigger during the upgrade process? Maybe you can quickly check if the trigger is still there after running the whole upgrade process?. I quickly grep'd the upgrade scripts and I don't see any obvious code that would drop that trigger.

Best,

Collapse
Posted by Justis Peters on
Thanks, Victor. I think that's the issue. We're testing this on a copy of the database and it appears that the triggers on rel_constraints somehow didn't get restored.

Kind regards,
Justis

Collapse
Posted by Justis Peters on
Yes, that was the issue. Thanks again for the pointer.