Migration from Corda 3.x to 4.x for PostgreSQL require a manual workaround

Description

Upgrading Corda node from 3.x running against PostgreSQL to Corda 4.x fails with:

[ERROR] 13:31:19+0100 [main] changelog.ChangeSet. - Change Set migration/vault-schema.changelog-init.xml::1511451595465-22::R3.Corda failed. Error: ERROR: relation "vault_fungible_states" already exists [Failed SQL: CREATE TABLE "my_schema".vault_fungible_states (output_index INTEGER NOT NULL, transaction_id VARCHAR(64) NOT NULL, issuer_name VARCHAR(255), issuer_ref BYTEA, owner_name VARCHAR(255), quantity BIGINT)] {changeSet=migration/vault-schema.changelog-init.xml::1511451595465-22::R3.Corda, databaseChangeLog=master.changelog.json}
[ERROR] 13:31:19+0100 [main] internal.NodeStartupLogging. - Could not create the DataSource: Migration failed for change set migration/vault-schema.changelog-init.xml::1511451595465-22::R3.Corda:
Reason: liquibase.exception.DatabaseException: ERROR: relation "vault_fungible_states" already exists [Failed SQL: CREATE TABLE "my_schema".vault_fungible_states (output_index INTEGER NOT NULL, transaction_id VARCHAR(64) NOT NULL, issuer_name VARCHAR(255), issuer_ref BYTEA, owner_name VARCHAR(255), quantity BIGINT)]: Could not create the DataSource: Migration failed for change set migration/vault-schema.changelog-init.xml::1511451595465-22::R3.Corda:
Reason: liquibase.exception.DatabaseException: ERROR: relation "vault_fungible_states" already exists [Failed SQL: CREATE TABLE "my_schema".vault_fungible_states (output_index INTEGER NOT NULL, transaction_id VARCHAR(64) NOT NULL, issuer_name VARCHAR(255), issuer_ref BYTEA, owner_name VARCHAR(255), quantity BIGINT)] [errorCode=euq4co, moreInformationAt=https://errors.corda.net/ENT/4.3-SNAPSHOT/euq4co]

 

The workaround is to manually create a dumy table e.g. "NODE_DUMMY" (wrapped by double quotes).

This is beacuse the Corda 4.x tries to recreate all tables as it doesn’t recogize this is already an existing database.
The internal check for existing database uses a table name written in upper cases ("NODE%"), it should have a check for lower case name as well.

Assignee

Alexey Chernikov

Reporter

Szymon Sztuka

Labels

Sprint

None

Epic Link

None

Priority

Low

Engineering Teams

None

Fix versions

Affects versions

Ported to...

None

Story Points / Dev Days

None

Build cut

None

Feature Team

Operational Experience
Configure