forked from mtusi2026/mtusi2026lab3
лабораторная работа 3
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
-- Lab3 shared idempotency ledger for POST message retries.
|
||||
--
|
||||
-- Scope is (user_id, HTTP method + chat path, key); the stored row carries the
|
||||
-- canonical request hash and the exact 201 body so any replica can replay the
|
||||
-- same Message. Rows expire after IDEMPOTENCY_TTL_SECONDS (default 24h).
|
||||
create table if not exists idempotency_keys (
|
||||
user_id uuid not null references users (id) on delete cascade,
|
||||
scope text not null,
|
||||
key text not null,
|
||||
request_hash text not null,
|
||||
status_code integer not null,
|
||||
response_body jsonb not null,
|
||||
created_at timestamptz not null default now(),
|
||||
expires_at timestamptz not null,
|
||||
primary key (user_id, scope, key)
|
||||
);
|
||||
|
||||
create index if not exists idempotency_keys_expires_at_idx
|
||||
on idempotency_keys (expires_at);
|
||||
Reference in New Issue
Block a user