I am trying to use CUBA with Heroku.
Heroku specifies that you should use the environment var DATABASE_URL to connect to their PostgreSQL database. They describe that you should not copy paste the credentials because they could change, but this is what the CUBA documentation tells me to do.
The DATABASE_URL is in an invalid URI format, so they provided the environment variable JDBC_DATABASE_URL.
I configured UberJar to use this environment variable like so:
For some reason my UberJar can still not find (after adding the spring profile) the postgres driver:
Caused by: java.lang.RuntimeException: Failed to load driver class org.postgresql.Driver in either of HikariConfig class loader or Thread context classloader
Edit: I noticed this happened after I chose my ‘local’ datasource to be HSQL. I added the dependency manually:
First - if you plan to use PostgreSQL at deployment time, it is a good idea to permanently switch your project to use PostgreSQL in Main data store settings.
Because databases do differ in their behavior, and you risk catching some problems only at deployment time if you don’t code and test your application with Postgres.
HSQL is good only for fast prototyping, it’s not for serious development.
To make your project be able to work with Postgres without permanently switching main DBMS from HSQL, you need to:
add JDBC driver dependency to build.gradle
run CUBA -> Generate Database scripts to generate database init scripts for postgres. Otherwise database schema will not be able to initialize.
set “cuba.dbmsType” at some point, e.g. in UberJar building task arguments.
We intend to work with a team on the same project. I would like to have the minimum set of instructions for the developers, so having the HSQL local database was perfect. To instruct them to start Postgres (on docker or something) is a little more cumbersome. Or is there some sort of support within Cuba (studio)? Sharing a network database would also be possible but not ideal I would say for local development.
I don’t see any problem for every developer to install local PostgreSQL. It has installers for all operating systems, it’s free to use, it’s not hard to install.
And there are Docker images available, if you like to Docker-ize everything.