1

I switched to Corda Enterprise mainly to try how it handles automated database migration. In the documentation here it says tools-database-manager generates only SQL version of Liquibase script for initial DB and SQL version is Database specific so should not be used for production.

But it is possible to generate the XML also with liqubase cmd using this command: /snap/bin/liquibase --url="jdbc:h2:tcp://localhost:10039/node" --driver=org.h2.Driver --classpath=/home/corda/Downloads/h2.jar generateChangeLog

which I did, and then I had to remove all the chnagelogs which are related to corda internal tables, and left only the ones that are my own and it seems everything works.

So the question is - may this approach have some hidden dangers that I don't know. Why otherwise Corda team developed tools-database-manager, and why they don't yet support xml generation with tools-database-manager?

And this leads to another question - what if I for example forget to include one of my tables in the initial script? Seems corda does not complain about it. Won't my table be created? Will I be able to ever migrate that table if it is missing in the initial script?

Andranik
  • 2,729
  • 1
  • 29
  • 45

1 Answers1

0

Firstly tools-database-manager is a helper tool available to make it easy for developers to perform database migration.

Let’s say you have 2 nodes in your network, each using a different database. PartyA uses PostgreSQL and PartyB uses Oracle. If PartyA uses this tool to create the migration script by connecting to PostgreSQL, this will out SQL statements specific to PostgreSQL.

Hence this is not portable and hence it's said the generated script is database specific.

Also, you do not want to trust a script and fire it directly on your production database, it contains DDL statements, so it is strongly recommended that every time a script is generated, make sure you know what the script is doing by manually looking into it.

There are a lot of enhancements going on in this space, supporting XML for migration script being one of them.

As mentioned earlier, you should manually look at the migration script. If you forget to add one of your table, Corda will not complain. It will fail sometime later when from within your code you try to access this table.

Yes, you can stop the node and create the table again by adding a create table script.

Sneha Damle
  • 604
  • 1
  • 5
  • 6