code: private function findPk(&$fields)
      {
          $pk = null;
          foreach ($fields as $column => $field) {
              if ($field->config['primary'] == true) {
                  $pk = $column;
                  break;
              }
          }
  
          // If there isn't a primary key defined then add a default one
          if (is_null($pk)) {
              $pk = 'id';
              $fields[$pk] = new Type\IntegerField(array('primary' => true));
          }
  
          return $pk;
      }
docs: Find pk