feat(domain,db): lab5 add outbox entry, transaction contract and 0006 migration
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user