Unexpected error running Liquibase: ERROR: relation "databasechangelog" does not exist - liquibase

When running a liquibase (version 3.5.3) deployment against a new postgres database, we are getting the error below. The table, databasechangelog, did not get created by liquibase, but the table, databasechangeloglock, did get created.
INFO 2/7/17 1:27 PM: liquibase: Successfully acquired change log lock
INFO 2/7/17 1:27 PM: liquibase: Successfully released change log lock
Unexpected error running Liquibase: ERROR: relation "audit.databasechangelog" does not exist
Position: 20
SEVERE 2/7/17 1:27 PM: liquibase: ERROR: relation "audit.databasechangelog" does
not exist
Position: 20
liquibase.exception.DatabaseException: Error executing SQL SELECT MD5SUM FROM au
dit.databasechangelog WHERE MD5SUM IS NOT NULL LIMIT 1: ERROR: relation "audit.d
atabasechangelog" does not exist
Position: 20
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:68)
at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:126)
at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:134)
at liquibase.executor.jvm.JdbcExecutor.queryForList(JdbcExecutor.java:20
0)
at liquibase.executor.jvm.JdbcExecutor.queryForList(JdbcExecutor.java:19
4)
at liquibase.changelog.StandardChangeLogHistoryService.init(StandardChan
geLogHistoryService.java:212)
at liquibase.Liquibase.checkLiquibaseTables(Liquibase.java:1124)
at liquibase.Liquibase.update(Liquibase.java:205)
at liquibase.Liquibase.update(Liquibase.java:192)
at liquibase.integration.commandline.Main.doMigration(Main.java:1130)
at liquibase.integration.commandline.Main.run(Main.java:188)
at liquibase.integration.commandline.Main.main(Main.java:103)
Caused by: org.postgresql.util.PSQLException: ERROR: relation "audit.databasecha
ngelog" does not exist
Position: 20
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryEx
ecutorImpl.java:2455)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutor
Impl.java:2155)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.ja
va:288)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:430)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:356)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:303
)
at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:289
)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:266
)
at org.postgresql.jdbc.PgStatement.executeQuery(PgStatement.java:233)
at liquibase.executor.jvm.JdbcExecutor$QueryStatementCallback.doInStatem
ent(JdbcExecutor.java:345)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)
... 11 more
There are two schemas, ods and audit. And the search_path is ods, audit, public. We specify the target schema in the connection string (currentSchema=audit). Additionally, we ran successfully against the ods schema.
As a workaround, we can manually create the log table. However, I am wondering if this is a bug with liquibase or if we are doing something wrong? My thought is that liquibase is somehow seeing the ods.databasechangelog and skips creating it.
Any thoughts would be appreciated.
m

Maybe try to use following liquibase parameter:
--defaultSchemaName=<schema>

Related

Liquibase error when Comment at the end of sql file

When add any comments to the end of sql file liquibase raises an error.
Everything is ok in any other places.
What are we doing wrong?
version 4.1.1 #10 built at 2020-10-12 19:24+0000 Starting Liquibase at 09:43:04 (version 4.1.1 #10 built at 2020-10-12 19:24+0000) Unexpected error running Liquibase: Migration failed for change set 1000.file_name.sql::1::10000: Reason: liquibase.exception.DatabaseException: Invalid SQL type: sqlKind = UNINITIALIZED [Failed SQL: (17439) – problem comment] For more information, please use the --logLevel flag
--liquibase formatted sql
--changeset 1:10000 stripComments:false runOnChange:true endDelimiter:;
alter table SCHEMA_NAME.SOME_TABLE modify
"ANY_COLOMN varchar2(60 char)
;
commit
;
-- problem comment
UPD
The command I'm running:
liquibase.bat --driver=oracle.jdbc.OracleDriver --username=yyyy --password=xxxx --url=jdbc:oracle:thin:#(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=some_host.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=some_servicename))) --changeLogFile=db-changelog-test.yml update
db-changelog-test.yml
---
databaseChangeLog:
- include:
file: 1000.file_name.sql
relativeToChangelogFile: true
liquibase.bat: modified only one string
IF NOT DEFINED JAVA_OPTS set JAVA_OPTS=-Dfile.encoding=UTF-8

custom properties in liquibase.properties file

I am using liquibase 2.0.5 and my properties file looks like below
#liquibase.properties
url=jdbc:oracle:thin:#//localhost:1521/orcl
username=myschama
password=myschama
masterUsername=system
masterPassword=system
I want to use system user to create myschema user. Currently, I get the following error.
Unexpected error running Liquibase: Unknown parameter: 'masterUsername'
SEVERE 12/21/17 12:59 PM:liquibase: Unexpected error running Liquibase: Unknown parameter: 'masterUsername'
liquibase.exception.CommandLineParsingException: Unknown parameter: 'masterUsername'
at liquibase.integration.commandline.Main.parsePropertiesFile(Main.java:387)
at liquibase.integration.commandline.Main.main(Main.java:122)
Is it possible to have such custom values in the properties file
If you want to use it in your changeSets as property, e.g.
<changeSet ...>
<sql>
INSERT INTO myTab(some_column) VALUES ('${masterUsername}')
</sql>
</changeSet>
then try putting this into your liquibase.properties:
parameter.masterUsername=your_desired_value
As an alternative, you can pass these on the command line as Java properties, e.g.
liquibase update ... -DmasterUsername=your_desired_value
See http://www.liquibase.org/documentation/changelog_parameters.html and http://www.liquibase.org/documentation/command_line.html for details.

liquibase always creates procedure in public schema in Postgres

I am trying to create SP in Postgres using liquibase and passing schemaName but it always create SP under public schema. My change set looks like
> <createProcedure relativeToChangelogFile="true"
> dbms="postgresql"
> path="storeProcedures/cirrus_UTC_Timestamp.sql"
> schemaName="cirrusdb"
> procedureName="cirrus_UTC_Timestamp">
> </createProcedure>
Debug log from Liquibase command
C:/views/P4V/cirrus_dev/cirrus/main/build/package/src/main/resources/scripts/MasterDBChangeLogs.xml:
C:/views/P4V/cirrus_dev/cirrus/main/build/package/src/main/resources/scripts/MasterDBChangeLogs.xml::8.2.0.0-1::guptaa8:
Computed checksum for create Procedure:[
dbms="postgresql"
path="storeProcedures/cirrus_UTC_Timestamp.sql"
procedureName="cirrus_UTC_Timestamp"
relativeToChangelogFile="true"
schemaName="cirrusdb" ] as 75cfb2062231cfb7a0813a82a4f62764 DEBUG 11/18/15 2:38 PM: liquibase:
C:/views/P4V/cirrus_dev/cirrus/main/build/package/src/main/resources/scripts/MasterDBChangeLogs.xml:
C:/views/P4V/cirrus_dev/cirrus/main/build/package/src/main/resources/scripts/MasterDBChangeLogs.xml::8.2.0.0-1::guptaa8:
Computed checksum for 7:75cf
b2062231cfb7a0813a82a4f62764:7:0a8a327c03ced9a7b29acb65fee085b9 as
0591c7cae23e75e7ea48680d9e7fb742 DEBUG 11/18/15 2:38 PM: liquibase:
C:/views/P4V/cirrus_dev/cirrus/main/build/package/src/main/resources/scripts/MasterDBChangeLogs.xml:
C:/views/P4V/cirrus_dev/cirrus/main/build/package/src/main/resources/scripts/MasterDBChangeLogs.xml::8.2.0.0-1::guptaa8:
Computed checksum for 7:0591 c7cae23e75e7ea48680d9e7fb742: as
ae8a55a46214d182fab4b59f8765b90d DEBUG 11/18/15 2:38 PM: liquibase:
Release Database Lock DEBUG 11/18/15 2:38 PM: liquibase: Executing
UPDATE database command: UPDATE cirrusdb.databasechangeloglock SET
LOCKED = FALSE, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1 INFO
11/18/15 2:38 PM: liquibase: Successfully released change log lock
Liquibase Update Successful
Liquibase Version: 3.4.1, Postgres version 9.3
After some research I found that liquibase (up to 3.4.2) does not support the schemaName on the createProcedure tag, its 'informational' only:
Source : https://liquibase.jira.com/browse/CORE-2626
Ticket Description :
Currently the createProcedure schemaName is not used, it is just for
informational purposes. Change createProcedure so if schemaName is
specified, it will use the SqlParser class to find the name of the
procedure in the body and either prepend the schema or replace the
existing schema with the given schemaName. Add a new
liquibase.useProcedureSchema=true|false flag which if false will not
do the parsing but instead add an ALTER SESSION USE DEFAULT SCHEMA...
statements before and after the create procedure SQL.

FAILED: Error in metadata:

when i am trying to show tables from hive databases the following error displays..
i granted permissions to ware house & Tables even though the error shows
hive> show tables;
FAILED: Error in metadata: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask
Thanks in advance.
this error occurs when hive CLI is terminated improperly.
solution:
exit from hive, give 'jps' command. some process named runjar will be there. kill it using ' kill -9 pid'
thats it. you are done.
plz ignore typo- replied from mobile

Not able to generate liquibase changelog

I am trying to execute command on my command prompt:
liquibase --driver=com.mysql.jdbc.Driver --classpath=E:\mysqljar\mysql.jar --changeLogFile=E:\1.xml --url="jdbc:mysql://localhost:3306/abc" --username=root --password=root generateChangeLog
But I am getting this error:
Liquibase Update Failed: Empty result set, expected one row
SEVERE 24/9/13 6:29 PM:liquibase: Empty result set, expected one row
liquibase.exception.DatabaseException: Error getting jdbc:mysql://localhost:3306/abc view with liquibase.statement.core.GetViewDefinitionStatement#53330681
at liquibase.snapshot.jvm.JdbcDatabaseSnapshotGenerator.readView(JdbcDatabaseSnapshotGenerator.java:168)
at liquibase.snapshot.jvm.JdbcDatabaseSnapshotGenerator.readViews(JdbcDatabaseSnapshotGenerator.java:304)
at liquibase.snapshot.jvm.JdbcDatabaseSnapshotGenerator.createSnapshot(JdbcDatabaseSnapshotGenerator.java:241)
at liquibase.snapshot.DatabaseSnapshotGeneratorFactory.createSnapshot(DatabaseSnapshotGeneratorFactory.java:69)
at liquibase.diff.Diff.compare(Diff.java:63)
at liquibase.integration.commandline.CommandLineUtils.doGenerateChangeLog(CommandLineUtils.java:145)
at liquibase.integration.commandline.Main.doMigration(Main.java:760)
at liquibase.integration.commandline.Main.main(Main.java:134)
Caused by: liquibase.exception.DatabaseException: Empty result set, expected one row
at liquibase.util.JdbcUtils.requiredSingleResult(JdbcUtils.java:124)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:159)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:167)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:163)
at liquibase.database.AbstractDatabase.getViewDefinition(AbstractDatabase.java:748)
at liquibase.snapshot.jvm.JdbcDatabaseSnapshotGenerator.readView(JdbcDatabaseSnapshotGenerator.java:166)
... 7 more
Could anyone help me to interpret this?
I had the same problem.
My fix:
There needs to be an entry in the database change log lock table; it needs to have id=1, locked=false and the rest of the values set to null.
I'm getting the same error also using MySQL and tried v3.0.0 and 3.0.5 of liquibase. The error was the same when I tried to do a migrate as well as a generateChangeLog.
./liquibase --logLevel=debug --changeLogFile=./db.changelog-test-v0.1.xml --username=abc --password=abc99 --url="jdbc:mysql://localhost:3306/test" migrate
FYI, here is the select statement that it had trouble executing for the 'migrate' command:
select view_definition from information_schema.views where table_name='patient_info' and table_schema='test'
The information_schema.views table is empty.