title: How do I write a Doctrine migration which can redistribute data into new tables
body: <p>I have a database (which was actually created using Propel in a Symfony1 application). I am reimplementing it in Symfony2 and Doctrine, but I also want to take the opportunity to refactor the database somewhat. </p>
  
  <p>I have defined a set of Doctrine Entities and run doctrine:migrations:diff, which has created me a basic Migration to add tables, columns and constraints, and drop a load of columns.</p>
  
  <p>However, before dropping these columns I want to copy the data into some of the new tables, and then link the new records in these table to new columns in the first table. I don't believe it's possible to do this in pure SQL (in general, the contents of one table are being distributed among three or four tables). </p>
  
  <p><a href="https://stackoverflow.com/questions/19502630/use-entitymanager-in-migrations-file">This</a> gave me a hint, and caused me to find <a href="http://symfony.com/doc/current/bundles/DoctrineMigrationsBundle/index.html#container-aware-migrations" rel="noreferrer">this</a> (which I had skipped, because I had no idea what relevance "containers" might be to my problem). </p>
  
  <p>But what I have not found anywhere in the Symfony or Doctrine documentation is an example of actually moving data around in a migration - which to me seems to be one of the core purposes of migrations!</p>
  
  <p>It is possible that I could use the hints in those links above, but then I'm not sure how to proceed. I do not have (and don't really want to take the time to create, though I'm sure I could do) Doctrine entities for the existing database schema: can I then use DQL? I simply don't know. </p>
  
  <p>So two questions: </p>
  
  <ol>
  <li><p>Can somebody give me an example of a Doctrine migration which moves data between tables?</p></li>
  <li><p>Alternatively, can anybody clarify how dependent the syntax of DQL is on the definitions of the Entities in Doctrine? Can I use it to specify columns which are not in the Entity definitions?</p></li>
  </ol>