title: How can a set PostgreSQL schema on the fly using Doctrine and Symfony?
body: <p>I'm trying to create a multi tenent app using Symfony 2.6 and PostgreSQL schemas (namespaces). I would like to know how can I change some entity schema on the pre persist event? </p>
  
  <p>I know that it's possible to set the schema as annotation <code>@Table(schema="schema")</code> but this is static solution I need something more dynamic!</p>
  
  <p>The purpose using PostgreSQL is take advantage of schemas feature like:</p>
  
  <pre><code>CREATE TABLE tenant_1.users (
      # table schema
  );
  
  CREATE TABLE tenant_2.users (
      # table schema
  );
  </code></pre>
  
  <p>So, if I want only users from tenant_2 my query will be something like <code>SELECT * FROM tenant_2.users;</code></p>
  
  <p>This way my data will be separated and I will have only one database to connect and maintain.</p>