diff --git a/stovepipe/extension/storage/mysql/schema/request_history.sql b/stovepipe/extension/storage/mysql/schema/request_history.sql new file mode 100644 index 000000000..e3ce05e75 --- /dev/null +++ b/stovepipe/extension/storage/mysql/schema/request_history.sql @@ -0,0 +1,18 @@ +-- request_history retains one append-only row per logical request occurrence. Exactly one of +-- state and event is populated; the remaining sparse columns carry the bounded context required +-- by that occurrence. +CREATE TABLE IF NOT EXISTS request_history ( + queue VARCHAR(255) NOT NULL, + request_id VARCHAR(255) NOT NULL, + entry_id VARCHAR(255) NOT NULL, + timestamp_ms BIGINT NOT NULL, + state VARCHAR(64) NOT NULL DEFAULT '', + event VARCHAR(64) NOT NULL DEFAULT '', + request_version INT NOT NULL DEFAULT 0, + superseded_by_request_id VARCHAR(255) NOT NULL DEFAULT '', + build_id VARCHAR(255) NOT NULL DEFAULT '', + outcome_reason VARCHAR(64) NOT NULL DEFAULT '', + fact_degree DOUBLE NOT NULL DEFAULT 0, + PRIMARY KEY (queue, request_id, entry_id), + KEY idx_request_history_order (queue, request_id, timestamp_ms, entry_id) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/test/integration/stovepipe/extension/storage/mysql/storage_test.go b/test/integration/stovepipe/extension/storage/mysql/storage_test.go index a2f312cd5..8915f850c 100644 --- a/test/integration/stovepipe/extension/storage/mysql/storage_test.go +++ b/test/integration/stovepipe/extension/storage/mysql/storage_test.go @@ -100,6 +100,7 @@ func resetStorage(t *testing.T, db *sql.DB) { t.Helper() for _, statement := range []string{ + "TRUNCATE TABLE request_history", "TRUNCATE TABLE request_uri", "TRUNCATE TABLE request", "TRUNCATE TABLE build",