Index: openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.9.0d4-5.9.0d5.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.9.0d4-5.9.0d5.sql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.9.0d4-5.9.0d5.sql	27 Jul 2015 12:52:59 -0000	1.2
+++ openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.9.0d4-5.9.0d5.sql	29 Jul 2015 02:08:43 -0000	1.3
@@ -1,8 +1,8 @@
-ALTER TABLE acs_objects drop column tree_sortkey cascade;
-ALTER TABLE acs_objects drop column max_child_sortkey cascade;
+ALTER TABLE acs_objects drop column IF EXISTS tree_sortkey cascade;
+ALTER TABLE acs_objects drop column IF EXISTS max_child_sortkey cascade;
 
-DROP TRIGGER  IF EXISTS acs_objects_insert_tr on acs_objects;
-DROP TRIGGER  IF EXISTS acs_objects_update_tr on acs_objects;
+DROP TRIGGER IF EXISTS acs_objects_insert_tr on acs_objects;
+DROP TRIGGER IF EXISTS acs_objects_update_tr on acs_objects;
 
 -- 
 -- procedure content_type__refresh_view/1
@@ -229,7 +229,7 @@
      --
      -- now the same with download_arch_revisions_obj
      --
-     select 1 from pg_class into success where relname = 'download_repository_obj';
+     select 1 from pg_class into success where relname = 'download_arch_revisions_obj';
      IF found THEN
         drop view download_arch_revisions_obj;
      END if;
@@ -262,6 +262,6 @@
 --    drop trigger acs_objects_insert_tr on acs_objects;
 --    drop trigger acs_objects_update_tr on acs_objects;
 
-drop function acs_objects_get_tree_sortkey(integer);
-drop function acs_objects_insert_tr();
-drop function acs_objects_update_tr();
+drop function IF EXISTS acs_objects_get_tree_sortkey(integer);
+drop function IF EXISTS acs_objects_insert_tr();
+drop function IF EXISTS acs_objects_update_tr();
