Forum OpenACS Development: Re: jiml's file storage fixes thread

Collapse
Posted by Jim Lynch on
First, there are some missing on delete cascades. The following code should go in a postgres upgrade script; not sure it works in oracle.

Reason for this: attempting to delete a file storage instance results in the foreign key constraint violation named by the constraint below.

alter table 
    fs_root_folders 
drop constraint 
    fs_root_folder_folder_id_fk;

alter table 
    fs_root_folders 
add constraint 
    fs_root_folder_folder_id_fk 
        foreign key (folder_id) 
        references cr_folders 
            on delete cascade;

This diff alters the HEAD version of file storage as of the date of this message, so that new installs will add "on delete cascade" to the fk constraint.

Index: file-storage-create.sql
===================================================================
RCS file: /cvsroot/openacs-4/packages/file-storage/sql/postgresql/file-storage-create.sql,v
retrieving revision 1.22
diff -u -r1.22 file-storage-create.sql
--- file-storage-create.sql     26 May 2005 08:28:45 -0000      1.22
+++ file-storage-create.sql     9 Sep 2009 02:55:50 -0000
@@ -38,7 +38,7 @@
     -- JS: It is superfluous, and causes a lot of RI headaches
     folder_id   integer
                 constraint fs_root_folder_folder_id_fk
-                references cr_folders
+                references cr_folders on delete cascade
                 constraint fs_root_folder_folder_id_un
                 unique
 );