-- ============================================================
-- LIVE CHAT — Tabel chat_messages
-- ============================================================
CREATE TABLE IF NOT EXISTS chat_messages (
    id          INT AUTO_INCREMENT PRIMARY KEY,
    email       VARCHAR(100)  NOT NULL COMMENT 'email member dari BukaOlshop (key identitas)',
    user_name   VARCHAR(100)  NOT NULL DEFAULT '',
    sender      ENUM('member','cs') NOT NULL,
    message     TEXT          NOT NULL,
    is_read     TINYINT(1)    NOT NULL DEFAULT 0,
    created_at  TIMESTAMP     DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_email   (email),
    INDEX idx_created (created_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
