Index: openacs-4/packages/acs-mail/sql/postgresql/acs-mail-queue-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail/sql/postgresql/acs-mail-queue-create.sql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/acs-mail/sql/postgresql/acs-mail-queue-create.sql	8 Jul 2001 18:40:49 -0000	1.2
+++ openacs-4/packages/acs-mail/sql/postgresql/acs-mail-queue-create.sql	13 Aug 2001 17:57:02 -0000	1.3
@@ -11,58 +11,57 @@
     'Queued Message',
     'Queued Messages',
     'acs_mail_link',
-    'ACS_MESSAGES_QUEUE_MESSAGE',
-    'MESSAGE_ID',
+    'acs_mail_queue_message',
+    'message_id',
     null,
     'f',
     null,
-    'ACS_OBJECT.DEFAULT_NAME'
+    'acs_object.default_name'
 );
 
 create table acs_mail_queue_messages (
-    message_id integer
-			   constraint acs_mail_queue_ml_id_pk 
-			   primary key
-			   constraint acs_mail_queue_ml_id_fk 
-			   references acs_mail_links
+    message_id		integer
+					constraint acs_mail_queue_ml_id_pk 
+					primary key
+					constraint acs_mail_queue_ml_id_fk 
+					references acs_mail_links on delete cascade
 );
 
 create table acs_mail_queue_incoming (
-    message_id integer
+    message_id		integer
 					constraint acs_mail_queue_in_mlid_pk 
 					primary key
-        constraint acs_mail_queue_in_mlid_fk
-            references acs_mail_queue_messages,
-    envelope_from text,
-    envelope_to text
+					constraint acs_mail_queue_in_mlid_fk
+					references acs_mail_queue_messages on delete cascade,
+    envelope_from	text,
+    envelope_to		text
 );
 
 create table acs_mail_queue_outgoing (
-    message_id integer
+    message_id		integer
 					constraint acs_mail_queue_out_mlid_pk 
 					primary key
-        constraint acs_mail_queue_out_mlid_fk
-            references acs_mail_queue_messages,
-    envelope_from text,
-    envelope_to text
+					constraint acs_mail_queue_out_mlid_fk
+					references acs_mail_queue_messages on delete cascade,
+    envelope_from	text,
+    envelope_to		text
 );
 
 -- API -----------------------------------------------------------------
 --create or replace package body acs_mail_queue_message__
-create function acs_mail_queue_message__new (integer,integer,
-integer,timestamp,integer,varchar,varchar)
+create function acs_mail_queue_message__new (integer,integer,integer,timestamp,integer,varchar,varchar)
 returns integer as '
 declare
 	p_mail_link_id			alias for $1;    -- default null
 	p_body_id				alias for $2;
 	p_context_id			alias for $3;    -- default null
-	p_creation_date			alias for $4;    -- default sysdate
+	p_creation_date			alias for $4;    -- default now()
 	p_creation_user			alias for $5;    -- default null
 	p_creation_ip			alias for $6;    -- default null
 	p_object_type			alias for $7;    -- default acs_mail_link
-    v_object_id     integer;
+    v_mail_link_id			acs_mail_links.mail_link_id%TYPE;
 begin
-    v_object_id := acs_mail_link__new (
+    v_mail_link_id := acs_mail_link__new (
 		p_mail_link_id,			-- mail_link_id 
 		p_body_id,				-- body_id 
 		p_context_id,			-- context_id 
@@ -75,19 +74,16 @@
     insert into acs_mail_queue_messages 
 	 ( message_id )
     values 
-	 ( v_object_id );
+	 ( v_mail_link_id );
 
-    return v_object_id;
+    return v_mail_link_id;
 end;' language 'plpgsql';
 
 create function acs_mail_queue_message__delete (integer)
 returns integer as '
 declare
 	p_message_id		alias for $1;
 begin
-    delete from acs_mail_queue_messages
-        where message_id = p_message_id;
-
 	perform acs_mail_link.delete( p_message_id );
 
     return 1;
