feat(domain,db): lab5 add outbox entry, transaction contract and 0006 migration

This commit is contained in:
Голиков Maximillian Антон
2026-11-06 22:43:56 +03:00
parent 18afe2563e
commit 7f0fb2b0da
4 changed files with 82 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
-- +goose Up
-- +goose StatementBegin
CREATE TABLE outbox (
id UUID PRIMARY KEY,
aggregate_type TEXT NOT NULL,
aggregate_id UUID NOT NULL,
event_type TEXT NOT NULL,
payload JSONB NOT NULL,
attempts INT NOT NULL DEFAULT 0,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
published_at TIMESTAMPTZ,
CONSTRAINT outbox_aggregate_type_len
CHECK (char_length(aggregate_type) BETWEEN 1 AND 64),
CONSTRAINT outbox_event_type_len
CHECK (char_length(event_type) BETWEEN 1 AND 64),
CONSTRAINT outbox_attempts_nonneg
CHECK (attempts >= 0)
);
CREATE INDEX outbox_pending_idx
ON outbox (created_at)
WHERE published_at IS NULL;
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE IF EXISTS outbox;
-- +goose StatementEnd