Index: openacs-4/packages/file-storage/sql/postgresql/file-storage-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/sql/postgresql/file-storage-drop.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/file-storage/sql/postgresql/file-storage-drop.sql 28 Aug 2001 23:08:46 -0000 1.2 +++ openacs-4/packages/file-storage/sql/postgresql/file-storage-drop.sql 30 Aug 2001 01:11:13 -0000 1.3 @@ -1,5 +1,5 @@ -- --- packages/file-storage/sql/file-storage-drop.sql +-- packages/file-storage/sql/postgresql/file-storage-drop.sql -- -- @author Kevin Scaldeferri (kevin@arsdigita.com) -- @creation-date 6 Now 2000 @@ -12,6 +12,20 @@ -- content repository is set up to cascade, so we should just have to -- delete the root folders -- +-- JS: The above is wrong. You cannot, for example, delete a folder with contents on it so +-- JS: trying to delete the root folder will raise an exception. Also, acs_object__delete +-- JS: is the wrong way to delete the items in CR. To delete a folder, for example, we must +-- JS: call content_folder__delete, which in turn calls acs_object__delete only through +-- JS: content_item__delete and only after cleaning up stuff). So if the package is deleted but +-- JS: there are still items in it, this drop script will fail. Perhaps it should, since it makes +-- JS: sense to delete the package only when the are no more stuff in it (perhaps moved elsewhere). +-- JS: Thus, an empty file storage is the only way this drop script will succeed. But then again, +-- JS: the package should not barf if indeed the admin wants to nuke the package and +-- JS: everything in it! (This is why deleting a package has a warning, I guess.) +-- JS: +-- JS: To delete properly, note: how did entries in fs_root_folders come about? Through APM! +-- JS: So we instead delete the *package instances*, and the triggers that we imposed on fs_root_folders +-- JS: will take care of cleaning up whatever items are in CR that are related to the package. create function inline_0() returns integer as ' @@ -20,10 +34,11 @@ begin for rec_root_folder in - select folder_id + select package_id from fs_root_folders loop - PERFORM acs_object__delete(rec_root_folder.folder_id); + -- PERFORM acs_object__delete(rec_root_folder.folder_id); + PERFORM apm_package__delete(rec_root_folder.package_id); end loop; return 0;