CREATE TABLE IF NOT EXISTS tax_idempotency (
    id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    request_hash CHAR(40) NOT NULL,
    ref_no VARCHAR(64) NOT NULL,
    status ENUM('Processing', 'Success', 'Failed') NOT NULL DEFAULT 'Processing',
    response_body MEDIUMTEXT NULL,
    created_at DATETIME NOT NULL,
    updated_at DATETIME NOT NULL,
    PRIMARY KEY (id),
    UNIQUE KEY uk_tax_idempotency_hash (request_hash),
    KEY idx_tax_idempotency_ref_no (ref_no),
    KEY idx_tax_idempotency_status_updated (status, updated_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

