title: Use EntityManager in Migrations file
body: <p>I have this code but does not work:</p>
  
  <pre><code>&lt;?php
  
  namespace Application\Migrations;
  
  use Doctrine\DBAL\Migrations\AbstractMigration,
      Doctrine\DBAL\Schema\Schema;
  
  /**
   * Auto-generated Migration: Please modify to your need!
   */
  class Version20131021150555 extends AbstractMigration
  {
  
      public function up(Schema $schema)
      {
          // this up() migration is auto-generated, please modify it to your needs
          $this-&gt;abortIf($this-&gt;connection-&gt;getDatabasePlatform()-&gt;getName() != "mysql", "Migration can only be executed safely on 'mysql'.");
  
          $this-&gt;addSql("ALTER TABLE person ADD tellphone LONGTEXT DEFAULT NULL");
  
          $em = $em = $this-&gt;getDoctrine()-&gt;getEntityManager();
          $persons = $em-&gt;getRepository('AutogestionBundle:Person')-&gt;fetchAll();
  
          foreach($persons as $person){
              $person-&gt;setTellPhone($person-&gt;getCellPhone());
              $em-&gt;persist($person);                                                                            
          }
          $em-&gt;flush(); 
      }
  
      public function down(Schema $schema)
      {
          // this down() migration is auto-generated, please modify it to your needs
          $this-&gt;abortIf($this-&gt;connection-&gt;getDatabasePlatform()-&gt;getName() != "mysql", "Migration can only be executed safely on 'mysql'.");
  
          $this-&gt;addSql("ALTER TABLE person DROP tellphone");
      }
  }
  </code></pre>
  
  <p>I have add info in cellphone in a new field tellphone.</p>
  
  <p>Thanks</p>