Running updateSQL for the first time gives database returned ROLLBACK error DatabaseException

Viewed 2285

I am using Liquibase v3.9 with PostgreSQL v11 for the first time. When testing out my changelog for the very first time I run updateSQL to see the output of the SQL that will be run against the database. I get this error:

Unexpected error running Liquibase: liquibase.exception.DatabaseException: org.postgresql.util.PSQLException: The database returned ROLLBACK, so the transaction cannot be committed. Transaction failure cause is <<ERROR: relation "public.databasechangeloglock" does not exist
      Position: 22>>
    For more information, please use the --logLevel flag
2 Answers

This happens because updateSQL is expecting databasechangelog table to exist, and if this is the first time you are running Liquibase against the database then those tables won't exist yet (they get created the first time you run liquibase update).

I do think this is a valid use case for running updateSQL, you can request this feature here:

https://github.com/liquibase/liquibase/issues

relation "public.databasechangeloglock" does not exist

I was with this issue using PostgreSQL in a container.

Then I realized the memory limit given to PostgreSQL was insufficient.

After Increasing PostgreSQL limit memory to 512MiB the problem was solved.

Related