Search code examples
postgresqlh2corda

Error While Setting up the PostgreSQL database instead of default H2


I'm trying to setup the postgresql database instead of default H2 database on development environment and I'm following the below resource

https://github.com/corda/samples/tree/database_migration_tutorial/database-migration-tutorial

While starting the nodes, getting some errors related to unknown properties (runMigration=true, database schema="schema name")

As I noticed on the above link, we need to have an enterprise jar to setup the same, so is it mandatory to have the Corda enterprise jar on dev to switch to postgresql database? if no, could you please let me know how can I proceed with the same?


Solution

  • The samples you're referencing are a little old, unfortunately.

    If you want to use postgres you generally only need to specify that in the node gradle config file:

    Something like this:

    node {
    
        ...
    
        extraConfig = [
            dataSourceProperties: [
                    dataSourceClassName : "org.postgresql.ds.PGSimpleDataSource",
                    'dataSource.url' : "jdbc:postgresql://localhost:5432/nodedb",
                    'dataSource.user' : "postgres",
                    'dataSource.password' : "pa$$w0rd"
            ],
            database: [
                    transactionIsolationLevel : "READ_COMMITTED"
            ]
        ]
    }
    

    You may also want to add the runSchemaMigration=true like they do in this example: https://github.com/corda/cordapp-template-java/blob/release-V4/build.gradle#L103

    Some useful resources for you: