Fault-tolerant delivery system
This commit is contained in:
14
migrations/20250901135528_create_idempotency_table.sql
Normal file
14
migrations/20250901135528_create_idempotency_table.sql
Normal file
@@ -0,0 +1,14 @@
|
||||
CREATE TYPE header_pair AS (
|
||||
name TEXT,
|
||||
value BYTEA
|
||||
);
|
||||
|
||||
CREATE TABLE idempotency (
|
||||
user_id UUID NOT NULL REFERENCES users (user_id),
|
||||
idempotency_key TEXT NOT NULL,
|
||||
response_status_code SMALLINT NOT NULL,
|
||||
response_headers header_pair[] NOT NULL,
|
||||
response_body BYTEA NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL,
|
||||
PRIMARY KEY (user_id, idempotency_key)
|
||||
);
|
||||
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE idempotency ALTER COLUMN response_status_code DROP NOT NULL;
|
||||
ALTER TABLE idempotency ALTER COLUMN response_body DROP NOT NULL;
|
||||
ALTER TABLE idempotency ALTER COLUMN response_headers DROP NOT NULL;
|
||||
@@ -0,0 +1,8 @@
|
||||
CREATE TABLE newsletter_issues (
|
||||
newsletter_issue_id UUID NOT NULL,
|
||||
title TEXT NOT NULL,
|
||||
text_content TEXT NOT NULL,
|
||||
html_content TEXT NOT NULL,
|
||||
published_at TIMESTAMPTZ NOT NULL,
|
||||
PRIMARY KEY (newsletter_issue_id)
|
||||
);
|
||||
@@ -0,0 +1,6 @@
|
||||
CREATE TABLE issue_delivery_queue (
|
||||
newsletter_issue_id UUID NOT NULL
|
||||
REFERENCES newsletter_issues (newsletter_issue_id),
|
||||
subscriber_email TEXT NOT NULL,
|
||||
PRIMARY KEY (newsletter_issue_id, subscriber_email)
|
||||
);
|
||||
Reference in New Issue
Block a user