title: Symfony2 Doctrine entity: How to create table in controller?
body: <p>I need some functionality for dynamic creation table in DB.
  Algorithm is: 
  1) register new user -> make record in DB (this is simple)
  2) after registration create table like <code>user_data_abcdef123456...</code> where <code>abcdef123456</code> - is random pregenerated hash. this table must created from (for example) existing default entity (user_data_)
  Entity:</p>
  
  <pre><code>Path\To\Entity\UserData:
      type: entity
      table: user_data_
  ....
  </code></pre>
  
  <p>in Controller do like this:</p>
  
  <pre><code>$doctrine = $this-&gt;getDoctrine();
  
  /** @var AbstractSchemaManager $manager */
  $manager = $doctrine-&gt;getConnection()-&gt;getSchemaManager();
  /** @var ClassMetadata $metadata */
  $metadata = $doctrine-&gt;getManager()-&gt;getClassMetadata($class);
  $metadata-&gt;setPrimaryTable(array('name' =&gt; $metadata-&gt;getTableName() . $project));
  
  $table = new Table($metadata-&gt;getTableName());
  $manager-&gt;createTable($table);
  </code></pre>
  
  <p>and I need set all column, all index.. etc.</p>
  
  <p>Is there any correct solution?</p>