title: How migrate to specific schema of database PostgreSQL working with Symfony and Doctrine?
body: <p>I did a migration after of created my database structure using <code>make:entity</code> command :</p>
  <blockquote>
  <p>$ symfony console make:migration</p>
  </blockquote>
  <p>Now, I want to migrate to a specific schema into my <code>PostgresSQL</code> database.</p>
  <p><a href="https://symfony.com/doc/current/bundles/DoctrineMigrationsBundle/index.html" rel="nofollow noreferrer">In the documentation</a> of Symfony says:</p>
  <p>MANUAL TABLES. It is a common use case, that in addition to your generated database structure based on your doctrine entities you might need custom tables. By default, such tables will be removed by the <code>doctrine:migrations:diff</code> command. If you follow a specific scheme you can configure doctrine/dbal to ignore those tables. Let’s say all custom tables will be prefixed by t_. In this case, you just have to add the following configuration option to your doctrine configuration:</p>
  <pre><code>doctrine: dbal: schema_filter: ~^(?!t_)~
  </code></pre>
  <p>I understand that <code>schema_filter</code> is a filter applied to table names (only tables?) through a regular expression. Well, but <code>schema_filter</code> no reference the schemas created into a <code>PostgreSQL</code> database.</p>
  <p>Then how can I migrate to a specific schema into a database?</p>
  <p>When I execute the command:</p>
  <blockquote>
  <p>$ symfony console make:migration</p>
  </blockquote>
  <p>it creates a migration file that contains a class with the functions 'up' and 'down', both with a parameter <code>$schema</code>. Here a fragment:</p>
  <pre><code> public function up(Schema $schema) : void
   {
       // this up() migration is auto-generated, please modify it to your needs
       $this-&gt;abortIf($this-&gt;connection-&gt;getDatabasePlatform()-&gt;getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
  
       $this-&gt;addSql('CREATE SEQUENCE division_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  </code></pre>
  <p>This parameter can't assign a value when it is declared. Must be null.</p>
  <p>Is it possible to use it to migrate to a specific schema?</p>
  <p>Well, while I find a way, I did it like this:</p>
  <p>public function up(Schema $schema) : void
  {
  // this up() migration is auto-generated, please modify it to your needs
  $this-&gt;abortIf($this-&gt;connection-&gt;getDatabasePlatform()-&gt;getName() !== 'postgresql', 'Migration can only be executed safely on 'postgresql'.');</p>
  <pre><code>     $this-&gt;addSql('CREATE SEQUENCE my_schema_name.division_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  </code></pre>
  <p>I mean that I write the schema name in all migration code generate by the command.</p>
  <p>But I still believe that is possible to do it in another way. If yes then how?</p>
  <p>I forgot it. Migration fails when I try with this line before of first sentence:</p>
  <pre><code> $this-&gt;addSql('SET search_path TO my_schema_name');
  </code></pre>
  <p>Also I try assigning the schema name to the parameter $schema:</p>
  <pre><code> $schema = 'my_schema_name'
  </code></pre>
  <p>It didn't work either.</p>