cancel
Showing results for 
Search instead for 
Did you mean: 

Problem when binding CAP application with PostgreSQL, Hyperscaler Option - No default database

edoardo-digix
Explorer
0 Kudos
305

Hi all,

recently I've been trying to connect a CAP application with an instance on the BTP of a PostgreSQL database. I actually managed to do so, meaning that I was able to deploy a Fiori application on my SAP Build Work Zone that can read and write to this instance of the "PostgreSQL, Hyperscaler Option" service (I verified so with PgAdmin). The problem is that to create this connection I just had to use the line "cds add postgres" to add the package "@cap-js/postgres" to my dependencies, so that when I generate the mta.yaml file all the necessary resources are added. When I deploy to Cloud Foundry, the application automatically connects with the instance of PostgreSQL and I'm not allowed to edit the details of the connection, including the specific database to which I desire to connect. This results in the fact that my application gets bound to the default database that gets created automatically.

Screenshot 2024-05-29 165253.png

What if I wanted to sync my data to a different database? If I had a nodejs application I'd just specify the desired database name in the "Pool" parameters. But here in CAP it seems that I can't specify any of those options.

Thanks in advance,

Edoardo

Accepted Solutions (0)

Answers (1)

Answers (1)

martin-kl
Explorer
0 Kudos

Hi Edoardo,

I'm not quite sure if you can change the db but we did manage to re-use a single db in multiple CAP applications by specifying the schema in the pool configuration. You can potentially change the db in there as well?

We specify the schema in the package.json "cds" config as follows:

"requires": {
  "db": {
    "credentials": {
      "schema": "yourschemaname"
    }
  }
}

Note: cds.requires.db has a "pool" property as well, you could check that too.

Best
Martin