Reputation: 6756
I am trying to integrate spring boot with postgres db. Everything works fine except that the tables are being created in the public schema even though I am specifying a particular schema in the application.properties
spring.datasource.schema=AngSpring
spring.jpa.database=POSTGRESQL
spring.datasource.platform=postgres
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.database.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/NGP_DB
spring.datasource.schema=AngSpring
spring.datasource.username=jdbcusr
spring.datasource.password=password
You can see in the postgres db screenshot that the task_list table is created under 'public' schema. According to the property file it should come under the 'AngSpring' schema.
Please correct me if Iam doing anything wrong in the code.
Upvotes: 0
Views: 1680
Reputation: 31679
I guess the spring.datasource.schema
property is used to specify the location of a concrete schema script file in your application to generate the database, so you should remove it.
Instead, it seems that you want to use the one that Hibernate guesses from your entitities and put it in an specific schema location in your postgres database. Use the schema in the url instead:
spring.datasource.url=jdbc:postgresql://localhost:5432/NGP_DB?currentSchema=AngSpring
See also:
Upvotes: 3