1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| CREATE TABLE IF NOT EXISTS CQRS_LDC_EVENT ( ID VARCHAR(36) NOT NULL, AGGREGATE_ID VARCHAR(36) NOT NULL, REVISION BIGINT NOT NULL,
EVENT JSON NOT NULL CHECK (JSON_VALID(EVENT)), TIMESTAMP DATETIME(6) NOT NULL DEFAULT LOCALTIMESTAMP,
IS_PUBLISHED BOOLEAN NOT NULL DEFAULT TRUE, CORRELATION_ID VARCHAR(36),
CONSTRAINT CQRS_LDC_EVENT_PK PRIMARY KEY(ID), CONSTRAINT CQRS_LDC_EVENT_AGGREGATE_ID_REVISION UNIQUE (AGGREGATE_ID, REVISION) );
CREATE TABLE IF NOT EXISTS CQRS_LDC_SNAPSHOT ( ID VARCHAR(36) NOT NULL, AGGREGATE_ID VARCHAR(36) NOT NULL, REVISION BIGINT NOT NULL,
STATE JSONB NOT NULL, TIMESTAMP TIMESTAMP(6) NOT NULL DEFAULT LOCALTIMESTAMP,
CONSTRAINT CQRS_LDC_SNAPSHOT_PK PRIMARY KEY(ID), CONSTRAINT CQRS_LDC_SNAPSHOT_AGGREGATE_ID_REVISION UNIQUE (AGGREGATE_ID, REVISION) );
|