Index: openacs-4/packages/download/sql/postgresql/download-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/download/sql/postgresql/download-drop.sql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/download/sql/postgresql/download-drop.sql	11 May 2001 05:20:01 -0000	1.2
+++ openacs-4/packages/download/sql/postgresql/download-drop.sql	14 May 2001 20:31:08 -0000	1.3
@@ -8,11 +8,15 @@
 returns integer as '
 declare
 	archive_rec			cr_items%ROWTYPE;
+	archive_child_rec	acs_object_context_index%ROWTYPE;
 begin
-	for archive_rec in select item_id from cr_items 
+	for archive_rec in select * from cr_items 
                          where content_type in ( ''cr_download_archive_desc'', 
 											     ''cr_download_archive'', 
 												 ''cr_download_rep'' ) loop
+		for archive_child_rec in select * from acs_object_context_index where ancestor_id = archive_rec.item_id loop
+			PERFORM content_item__delete( archive_child_rec.object_id );
+		end loop;
 		PERFORM content_item__delete( archive_rec.item_id );
 	end loop;
 
@@ -49,17 +53,19 @@
 
 /* Sequences */
 drop sequence download_archive_type_seq;
+drop view download_archive_type_sequence;
 drop sequence download_reasons_seq;
-drop sequence download_md_choice_id_sequence;
+drop view download_reasons_sequence;
+drop sequence download_md_choice_id_seq;
+drop view download_md_choice_id_sequence;
 drop sequence download_downloads_seq;
+drop view download_downloads_sequence;
 
 /* Views */
 drop view download_repository_obj;
 drop view download_archives_obj;
 drop view download_arch_revisions_obj;
 drop view download_downloads_repository;
---drop view download_archive_descsi;
---drop view download_archive_descsx;
 
 /* Tables */
 drop table download_downloads;
@@ -99,13 +105,13 @@
 	PERFORM content_type__drop_type (
 	  ''cr_download_archive'',
 	  ''t'',
-	  ''f''
+	  ''t''
 	);
 
 	PERFORM content_type__drop_type (
 	  ''cr_download_rep'',
 	  ''t'',
-	  ''f''
+	  ''t''
 	);
 
     return 0;
