-- Criar banco de dados
CREATE DATABASE IF NOT EXISTS provadevida_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

USE provadevida_db;

-- Tabela de logs de acesso
CREATE TABLE IF NOT EXISTS logs_acesso (
    id INT AUTO_INCREMENT PRIMARY KEY,
    token_id INT NOT NULL,
    ip_address VARCHAR(45),
    user_agent TEXT,
    acao VARCHAR(100),
    data_hora TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (token_id) REFERENCES tokens(id) ON DELETE CASCADE,
    INDEX idx_token_id (token_id),
    INDEX idx_data_hora (data_hora)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;