drieu
drieu

Reputation: 367

Grails with Postgresql : can't create table in appropriate schema

I want to use Grails 3.3.0 with a Postgresql database and also with three schema : openlearning, data and contrib. In domain classes, I specified the schema I want (see below). My issue is that tables are created only in public schema and not in the appropriate schema.

How can I do to create tables in the correct schema ?

note : Tables are all created in public schema.The other schema are created but are empty.They doesn't contain any table.

Question Domain class :

package fr.dr.openlearning
class Question {

 static mapping = {
 id generator: 'increment',params:[sequence:'incr']
 schema : "data"
}

application.yml :

dataSource:
  driverClassName: org.postgresql.Driver
  url: jdbc:postgresql://localhost:5432/openlearning
  username: postgres
  password: XXX
  pooled: true
  jmxExport: true


environments:
    development:
        dataSource:
            dbCreate: create-drop
        dataSources:
            data:
              dbCreate: create-drop
            contrib:
              dbCreate: create-drop

Upvotes: 1

Views: 470

Answers (2)

Syed Sarek
Syed Sarek

Reputation: 413

Follow these steps:

  1. Create a new schema in your database as Super Admin
  2. Change your username and password as your new schema in application.yml
  3. Change your dbCreate: create-drop to dbCreate: update

Upvotes: 1

kumar
kumar

Reputation: 41

In your application.yml file change the dbCreate: create-drop to dbCreate: create.

Upvotes: 1

Related Questions