Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql,v
diff -u -r1.13 -r1.14
--- openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql	30 Apr 2001 01:34:58 -0000	1.13
+++ openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql	1 May 2001 04:37:49 -0000	1.14
@@ -407,7 +407,31 @@
 create trigger cr_revisions_lob_trig before delete or update or insert
 on cr_revisions for each row execute procedure on_lob_ref();
 
+create function cr_check_revision_storage_tr () returns opaque as ' 
+declare
+        v_storage_type  cr_items.storage_type%TYPE;
+begin
+        select storage_type into v_storage_type
+        from cr_items
+        where item_id = new.item_id;
 
+        if (v_storage_type <> new.storage_type) or
+           (v_storage_type = ''lob'' and new.lob is null) or
+           ((v_storage_type = ''text'' or v_storage_type = ''file'') and
+            new.content is null) then
+
+           raise EXCEPTION ''Invalid storage type: % for revision_id = %'', new.storage_type, new.revision_id;
+           
+        end if;
+
+        return new;
+
+end;' language 'plpgsql';
+
+create trigger cr_check_revision_storage_tr before update or insert
+on cr_revisions for each row execute procedure cr_check_revision_storage_tr ();
+
+
 create index cr_revisions_by_mime_type on cr_revisions(mime_type);
 create index cr_revisions_title_idx on cr_revisions(title);
 -- create index cr_revisions_lower_title_idx on cr_revisions(lower(title));
