title: Spring Boot application doesn't create schemas for JPA @Table annotation
body: <p>I want to have tables located in different database schemas. But unfortunately, I can't achieve this with Spring Boot. Here steps to reproduce it.</p>
  
  <ol>
  <li><p>Create a new Spring Boot project on <a href="http://start.spring.io" rel="nofollow noreferrer">http://start.spring.io</a> version 2.0.5 (with derby and PostgreSQL dependencies)</p></li>
  <li><p>Create simple entity</p></li>
  </ol>
  
  <pre class="lang-java prettyprint-override"><code>@Entity
  @Table(name = "my_table")
  public class MyTable {
      @Id Integer id;
  }
  </code></pre>
  
  <ol start="3">
  <li>Add only next property to the application.properties with value 'update' or 'create' (if you try 'create-drop' then you get another error described here: <a href="https://github.com/spring-projects/spring-boot/issues/7706#issuecomment-268798059" rel="nofollow noreferrer">https://github.com/spring-projects/spring-boot/issues/7706#issuecomment-268798059</a>). Now Derby datasource will be used by default.</li>
  </ol>
  
  <p><code>spring.jpa.hibernate.ddl-auto=create</code></p>
  
  <ol start="4">
  <li><p>Run a generated test or main class. Be sure all works fine. </p></li>
  <li><p>Modify the entity, add attribute <code>schema</code> to the <code>@Table</code> annotation. Now the entity looks like:</p></li>
  </ol>
  
  <pre class="lang-java prettyprint-override"><code>@Entity
  @Table(name = "my_table", schema = "my_schema")
  public class MyTable {
      @Id Integer id;
  }
  </code></pre>
  
  <ol start="6">
  <li>Run a test (or main class). This time I get an error while Spring Boot initialization process "<code>java.sql.SQLSyntaxErrorException: Schema 'MY_SCHEMA' does not exist</code>":</li>
  </ol>
  
  <p>Full log listing is available here: <a href="https://gist.github.com/asaushkin/8d767c92b2e7025dd359f7be43eefdd6" rel="nofollow noreferrer">https://gist.github.com/asaushkin/8d767c92b2e7025dd359f7be43eefdd6</a></p>
  
  <ol start="7">
  <li>Check on PostgreSQL. This error reproduces on a PostgreSQL instance too. Without the 'schema' attribute Spring Boot app runs perfect, but as soon as this attribute appears on the @Table annotation the exceptions are thrown.</li>
  </ol>
  
  <p>Full log is here: <a href="https://gist.github.com/asaushkin/dd0d677964556bf943c4f013d4785372" rel="nofollow noreferrer">https://gist.github.com/asaushkin/dd0d677964556bf943c4f013d4785372</a></p>
  
  <p>My question is: <strong>why are schemas not created by Spring Boot?</strong></p>
  
  <p>These options can't resolve this issue too:</p>
  
  <pre><code>spring.jpa.properties.javax.persistence.schema-generation.create-database-schemas=true
  spring.jpa.properties.hibernate.hbm2dll.create_namespaces=true
  </code></pre>
  
  <p>Links</p>
  
  <ol>
  <li><a href="https://docs.jboss.org/hibernate/orm/5.2/userguide/html_single/Hibernate_User_Guide.html#configurations-hbmddl" rel="nofollow noreferrer">https://docs.jboss.org/hibernate/orm/5.2/userguide/html_single/Hibernate_User_Guide.html#configurations-hbmddl</a></li>
  <li><a href="https://docs.spring.io/spring-boot/docs/current/reference/html/howto-data-access.html#howto-configure-jpa-properties" rel="nofollow noreferrer">https://docs.spring.io/spring-boot/docs/current/reference/html/howto-data-access.html#howto-configure-jpa-properties</a></li>
  </ol>
  
  <p>Update (11 March 2019):</p>
  
  <p>I've just check the current behavior of the issue. I wonder, but currently with Derby driver all works fine and the table is created with the specified schema. But in PostgreSQL an error continues exists.</p>
  
  <p>Generated SQL (for PostgreSQL) is:</p>
  
  <pre class="lang-sql prettyprint-override"><code>create table my_schema.my_table (id int4 not null, primary key (id))
  </code></pre>