feat(platform): add the notification inbox and deterministic match search
This commit is contained in:
1 parent
5edff21d2d
commit
0b11021b16
169 files changed
+17083
-443
No files matched your search
@@ -0,0 +1,48 @@
|
||||
-- The inbox allowlist gains a synthetic event type. It carries no product
|
||||
-- meaning: it lets the consumer, the read-time visibility check, the list,
|
||||
-- and the read state run end to end before real producers exist. Each event
|
||||
-- type is bound to the one source type its content is resolved from.
|
||||
-- +goose Up
|
||||
ALTER TABLE notification_inbox_events
|
||||
DROP CONSTRAINT notification_inbox_events_type_known;
|
||||
|
||||
ALTER TABLE notification_inbox_events
|
||||
ADD CONSTRAINT notification_inbox_events_type_known CHECK (
|
||||
schema_version = 1
|
||||
AND (
|
||||
(event_type = 'invitation.delivered' AND source_type = 'invitation')
|
||||
OR (
|
||||
event_type = 'notification.synthetic_delivered'
|
||||
AND source_type = 'organization'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
-- A rollback must not silently lose or orphan recipient-visible history.
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DO $$
|
||||
BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM notification_inbox_events
|
||||
WHERE event_type <> 'invitation.delivered'
|
||||
) THEN
|
||||
RAISE EXCEPTION USING
|
||||
ERRCODE = 'integrity_constraint_violation',
|
||||
CONSTRAINT = 'notification_inbox_events_type_known',
|
||||
TABLE = 'notification_inbox_events',
|
||||
MESSAGE = 'synthetic notification inbox records must be resolved before rollback';
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
-- +goose StatementEnd
|
||||
|
||||
ALTER TABLE notification_inbox_events
|
||||
DROP CONSTRAINT notification_inbox_events_type_known;
|
||||
|
||||
ALTER TABLE notification_inbox_events
|
||||
ADD CONSTRAINT notification_inbox_events_type_known CHECK (
|
||||
event_type = 'invitation.delivered'
|
||||
AND schema_version = 1
|
||||
AND source_type = 'invitation'
|
||||
);
|
||||
Reference in new issue
Block a user