CREATE TABLE IF NOT EXISTS quiz_vote (
    id         INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    email      VARCHAR(255)     DEFAULT NULL,
    variant    SMALLINT UNSIGNED NOT NULL,
    ip         VARCHAR(45)      DEFAULT NULL,
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    UNIQUE KEY uq_email (email),
    INDEX idx_ip (ip)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Если таблица уже существует, обновить email на nullable и добавить ip:
-- ALTER TABLE quiz_vote MODIFY email VARCHAR(255) DEFAULT NULL;
-- ALTER TABLE quiz_vote ADD COLUMN ip VARCHAR(45) DEFAULT NULL AFTER variant, ADD INDEX idx_ip (ip);
