CREATE TABLE IF NOT EXISTS chats_messages (
    id_message INT UNSIGNED NOT NULL AUTO_INCREMENT,
    id_chat INT UNSIGNED NOT NULL,
    id_user INT UNSIGNED NULL,
    role VARCHAR(20) NOT NULL,
    content MEDIUMTEXT NOT NULL,
    model VARCHAR(190) NULL,
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (id_message),
    KEY idx_chat (id_chat),
    KEY idx_user (id_user)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
