Index: openacs-4/packages/notifications/sql/postgresql/notifications-core-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/sql/postgresql/notifications-core-create.sql,v
diff -u -r1.16 -r1.17
--- openacs-4/packages/notifications/sql/postgresql/notifications-core-create.sql	7 Jun 2008 20:29:00 -0000	1.16
+++ openacs-4/packages/notifications/sql/postgresql/notifications-core-create.sql	3 Oct 2018 09:11:50 -0000	1.17
@@ -120,22 +120,24 @@
     interval_id                     integer
                                     constraint notifications_request_interv_id_nn
                                     not null,
-    constraint notifications_request_interv_fk
-    foreign key (type_id, interval_id)
-    references notification_types_intervals (type_id, interval_id),
     -- the delivery method must be allowed for this type
     delivery_method_id              integer
                                     constraint notifications_request_delivery_meth_nn
                                     not null,
-    constraint notifications_request_deliv_fk
-    foreign key (type_id, delivery_method_id)
-    references notification_types_del_methods (type_id, delivery_method_id),
     -- the format of the notification should be...
     format                          varchar(100)
                                     default 'text'
                                     constraint notifications_request_format_ck
                                     check (format in ('text', 'html')),
-    dynamic_p                       bool default 'f'
+    dynamic_p                       bool default 'f',
+    constraint                      notifications_request_interv_fk
+                                    foreign key (type_id, interval_id)
+                                    references notification_types_intervals (type_id, interval_id),
+    constraint                      notifications_request_deliv_fk
+                                    foreign key (type_id, delivery_method_id)
+                                    references notification_types_del_methods (type_id, delivery_method_id),
+    constraint                      notification_requests_un
+                                    unique (type_id, user_id, object_id)
 );
 
 create index notification_requests_t_o_idx on notification_requests(type_id, object_id);
