Index: openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql,v
diff -u -r1.64 -r1.65
--- openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql	11 Aug 2006 21:58:04 -0000	1.64
+++ openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql	24 Sep 2006 09:26:36 -0000	1.65
@@ -1631,13 +1631,23 @@
 declare
    delete__package_id   alias for $1;
    cur_val              record;
+   v_folder_row         record;
 begin
     -- Delete all parameters.
     for cur_val in select value_id from apm_parameter_values
 	where package_id = delete__package_id loop
     	PERFORM apm_parameter_value__delete(cur_val.value_id);
     end loop;    
 
+   -- Delete the folders
+    for v_folder_row in select
+        folder_id
+        from cr_folders
+        where package_id = delete__package_id
+    loop
+        perform content_folder__del(v_folder_row.folder_id,''t'');
+    end loop;
+
     delete from apm_applications where application_id = delete__package_id;
     delete from apm_services where service_id = delete__package_id;
     delete from apm_packages where package_id = delete__package_id;
@@ -1646,6 +1656,7 @@
 	where object_id = delete__package_id loop
     	PERFORM site_node__delete(cur_val.node_id);
     end loop;
+
     -- Delete the object.
     PERFORM acs_object__delete (
        delete__package_id
