Index: openacs-4/contrib/packages/project-manager/sql/postgresql/project-manager-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/sql/postgresql/Attic/project-manager-drop.sql,v
diff -u -r1.6 -r1.7
--- openacs-4/contrib/packages/project-manager/sql/postgresql/project-manager-drop.sql	13 Aug 2003 18:56:29 -0000	1.6
+++ openacs-4/contrib/packages/project-manager/sql/postgresql/project-manager-drop.sql	13 Aug 2003 22:52:18 -0000	1.7
@@ -34,20 +34,23 @@
                 where 
                 content_type = ''pm_task''
         LOOP
-                
-                PERFORM pm_task__delete_task_item(v_item);
+                PERFORM pm_task__delete_task_item(v_item.item_id);
         end loop;
 
     return 0;
 end;
 ' language 'plpgsql';
 
--- select inline_0();
+select inline_0();
 drop function inline_0();
 
 select drop_package('pm_task');
 
 
+-----------
+-- PROJECTS
+-----------
+
 --drop permissions
 delete from acs_permissions where object_id in (select project_id from pm_projects);
 
@@ -58,19 +61,22 @@
     v_folder_id	  cr_folders.folder_id%TYPE;
     v_item_id     cr_items.item_id%TYPE;
     v_item_cursor RECORD;
-        
 begin
-    select content_item__get_id(''projects'', null, ''f'') into v_folder_id from dual;
 
     -- delete all contents of projects folder
     FOR v_item_cursor IN
-        select item_id
-        from   cr_items
-        where  parent_id = v_folder_id
+        select
+        item_id
+        from
+        cr_items
+        where
+        content_type = ''pm_project''
     LOOP
-       	PERFORM pm_projects__delete_project_item(v_item_cursor.item_id);
+       	PERFORM pm_project__delete_project_item(v_item_cursor.item_id);
     END LOOP;
 
+    select content_item__get_id(''projects'', null, ''f'') into v_folder_id from dual;
+
     -- unregister_content_types
     PERFORM content_folder__unregister_content_type (
         v_folder_id,		-- folder_id
@@ -84,41 +90,24 @@
     -- delete projects folder
     PERFORM content_folder__delete(v_folder_id);
 
+    -- delete the content folders
+    FOR v_item_cursor IN
+        select f.folder_id 
+        from   cr_folders f, 
+               cr_items   i
+        where  f.folder_id = i.item_id and 
+               description = ''Project Repository''
+    LOOP
+       	PERFORM content_item__delete(v_item_cursor.folder_id);
+    END LOOP;
+
     return 0;
 end;
 ' language 'plpgsql';
 
 select inline_0();
 drop function inline_0();
 
------------
--- PROJECTS
------------
-
--- delete content_type 'pm_project'
-
-create function inline_0 ()
-returns integer as '
-declare
-        v_pm_item       cr_items%ROWTYPE;
-begin
-        FOR v_pm_item in select
-                item_id
-                from
-                cr_items
-                where
-                content_type = ''pm_project''
-        LOOP
-                PERFORM pm_project__delete_project_item(v_pm_item.item_id);
-        END LOOP;
-        
-        return 0;
-end;
-' language 'plpgsql';
-
-select inline_0();
-drop function inline_0();
-
 -- drop package, which drops all functions created with define_function_args
 select drop_package('pm_project');
 
