I have postgres database on My server, I wanted to freeze its state and start using liqui from some point. While trying to generate changelog from current state i receive many strange messages and null pointer exception:
Reading tables for emsuser @ jdbc:postgresql://gucio:5432/emsserver (Default Schema: ems) ...
Reading foreign keys for emsuser @ jdbc:postgresql://gucio:5432/emsserver (Default Schema: ems) ...
Reading primary keys for emsuser @ jdbc:postgresql://gucio:5432/emsserver (Default Schema: ems) ...
Reading columns for emsuser @ jdbc:postgresql://gucio:5432/emsserver (Default Schema: ems) ...
2010-01-07 15:16:38 liquibase.database.structure.SqlDatabaseSnapshot readColumns
INFO: Could not find table or view hibernate_sequence for column sequence_name
2010-01-07 15:16:38 liquibase.database.structure.SqlDatabaseSnapshot readColumns
INFO: Could not find table or view hibernate_sequence for column last_value
2010-01-07 15:16:38 liquibase.database.structure.SqlDatabaseSnapshot readColumns
INFO: Could not find table or view hibernate_sequence for column start_value
2010-01-07 15:16:38 liquibase.database.structure.SqlDatabaseSnapshot readColumns
INFO: Could not find table or view hibernate_sequence for column increment_by
2010-01-07 15:16:38 liquibase.database.structure.SqlDatabaseSnapshot readColumns
INFO: Could not find table or view hibernate_sequence for column max_value
2010-01-07 15:16:38 liquibase.database.structure.SqlDatabaseSnapshot readColumns
INFO: Could not find table or view hibernate_sequence for column min_value
2010-01-07 15:16:38 liquibase.database.structure.SqlDatabaseSnapshot readColumns
INFO: Could not find table or view hibernate_sequence for column cache_value
2010-01-07 15:16:38 liquibase.database.structure.SqlDatabaseSnapshot readColumns
INFO: Could not find table or view hibernate_sequence for column log_cnt
2010-01-07 15:16:38 liquibase.database.structure.SqlDatabaseSnapshot readColumns
INFO: Could not find table or view hibernate_sequence for column is_cycled
2010-01-07 15:16:38 liquibase.database.structure.SqlDatabaseSnapshot readColumns
INFO: Could not find table or view hibernate_sequence for column is_called
2010-01-07 15:16:38 liquibase.database.structure.SqlDatabaseSnapshot readColumns
INFO: Could not find table or view nlt_client_pk for column id
2010-01-07 15:16:38 liquibase.database.structure.SqlDatabaseSnapshot readColumns
INFO: Could not find table or view nlt_subscription_pk for column id
2010-01-07 15:16:38 liquibase.database.structure.SqlDatabaseSnapshot readColumns
INFO: Could not find table or view nlt_synchronization_report_element_pk for column id
2010-01-07 15:16:38 liquibase.database.structure.SqlDatabaseSnapshot readColumns
INFO: Could not find table or view nlt_synchronization_report_pk for column id
2010-01-07 15:16:38 liquibase.database.structure.SqlDatabaseSnapshot readColumns
INFO: Could not find table or view primary_key_id for column id
Reading unique constraints for emsuser @ jdbc:postgresql://gucio:5432/emsserver (Default Schema: ems) ...
Reading indexes for emsuser @ jdbc:postgresql://gucio:5432/emsserver (Default Schema: ems) ...
Migration Failed: Unknown Reason. For more information, use the --logLevel flag)
2010-01-07 15:16:39 liquibase.commandline.Main main
SEVERE: Unknown Reason
java.lang.NullPointerException
at liquibase.database.structure.SqlDatabaseSnapshot.readIndexes(SqlDatabaseSnapshot.java:505)
at liquibase.database.structure.SqlDatabaseSnapshot.(SqlDatabaseSnapshot.java:99)
at liquibase.database.structure.PostgresDatabaseSnapshot.(PostgresDatabaseSnapshot.java:35)
at liquibase.database.PostgresDatabase.createDatabaseSnapshot(PostgresDatabase.java:447)
at liquibase.diff.Diff.compare(Diff.java:62)
at liquibase.commandline.CommandLineUtils.doGenerateChangeLog(CommandLineUtils.java:135)
at liquibase.commandline.Main.doMigration(Main.java:591)
at liquibase.commandline.Main.main(Main.java:97)
Liquibase generateChangeLog along with postgres wont work if there are more than two schemas in DB (one of them has to be public). Otherwise liquibase during dump tries to access to constraints that are from other schemas. When he does that, then this constraint do not have table name and this causes NullPointerException.
Thanks for finding the problem. It should not do that, I’ll create an issue for it, although I will probably not have a chance to look at it until 2.1. If you get a chance and a have a good database to test against, any patches would be greatly appreciated.
I just want to report that I’m getting this same error (NullPointerException in SqlDatabaseSnapshot.readIndexes(), at line 505), when trying to use a “columnExists” preCondition against a multi-schema Postgres database, using Liquibase 1.9.5.
PreConditions were one of the big reasons we upgraded to 1.9.5 - any chance there’s a fix available?
I got NullPointerException during generateChangeLog:
DEBUG 17.2.10 14:20:liquibase: Reading unique constraints for djaara @ jdbc:postgresql://127.0.0.1/lesk ...
INFO 17.2.10 14:20:liquibase: Reading unique constraints for djaara @ jdbc:postgresql://127.0.0.1/lesk ...
DEBUG 17.2.10 14:20:liquibase: Reading indexes for djaara @ jdbc:postgresql://127.0.0.1/lesk ...
INFO 17.2.10 14:20:liquibase: Reading indexes for djaara @ jdbc:postgresql://127.0.0.1/lesk ...
LiquiBase Update Failed: Unknown Reason
INFO 17.2.10 14:20:liquibase: Unknown Reason
java.lang.NullPointerException
at liquibase.snapshot.core.JdbcDatabaseSnapshotGenerator.readIndexes(JdbcDatabaseSnapshotGenerator.java:592)
at liquibase.snapshot.core.JdbcDatabaseSnapshotGenerator.createSnapshot(JdbcDatabaseSnapshotGenerator.java:208)
at liquibase.snapshot.DatabaseSnapshotGeneratorFactory.createSnapshot(DatabaseSnapshotGeneratorFactory.java:69)
at liquibase.diff.Diff.compare(Diff.java:65)
at liquibase.integration.commandline.CommandLineUtils.doGenerateChangeLog(CommandLineUtils.java:113)
at liquibase.integration.commandline.Main.doMigration(Main.java:605)
at liquibase.integration.commandline.Main.main(Main.java:105)
I am using PostgreSQL 8.4.2 with postgresql-8.4-701.jdbc3.jar driver.
I add some debug output to code and found constraint name which case this null pointer exception - uq_dbcl_orderexec. That unique constraint belongs to liquibses table databasechangelog. After constraint removal generateChangeLog works correctly.
Hmm, it seems that liquibase tables are “ignored” during readTables, but postgresql implementation of readUniqueConstraints will find unique keys for liquibase tables and that case problem - liquibase cannot find table for constraint.