SET @tableExists := (
    SELECT COUNT(*)
    FROM INFORMATION_SCHEMA.TABLES
    WHERE TABLE_SCHEMA = DATABASE()
      AND TABLE_NAME = 'nfse_logs_login'
);

SET @sql := IF(@tableExists = 0,
'CREATE TABLE nfse_logs_login (
id INT NOT NULL AUTO_INCREMENT,
log_login VARCHAR(100) NOT NULL,
data_login DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
ip_usuario VARCHAR(45) DEFAULT NULL,
navegador_usuario VARCHAR(255) DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;',
'SELECT "Tabela nfse_logs_login já existe."'
);

PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;