I am using liquibase version 4.3.x to create a table using formatted SQL file. I am running Jenkins job that runs shell script that invokes liquibase to executes sql file and the output shows only [2021-08-04 13:00:00] INFO [liquibase.changelog] Custom SQL executed. I am using --logLevel=info.
Questions
- Is there a way using liquibase to validate whether table has been successfully created on the MySQL database without having to ssh to the database server and running sql command from mysql client to verify the same?
- Can actual table creation output be logged into Liquibase log file so that DBA can verify that log file for actual execution of SQL statement?
The execution of custom sql should be shown in the Liquibase output. I’m using an older version of Liiquibase (3.10), with logLevel=info, and here is the output I see:
13:16:10.896 INFO [liquibase.executor.jvm.JdbcExecutor]: GRANT SELECT ON test_department TO read_only_role
13:16:10.900 INFO [liquibase.changelog.ChangeSet]: Custom SQL executed
13:16:10.902 INFO [liquibase.changelog.ChangeSet]: ChangeSet db-changelog-3.xml::grant_select_on_test_department::author1 ran success
Liquibase doesn’t validate that a table has been successfully created, but I suppose you could add a second changeset with a sqlcheck precondition to check for the table.
Thanks. Using liquibase Open Source version 4.3.x, I tried using infoLevel=debug but still, I am not able to get columns and data types of a table that I created via Liquibase using the command "desc <table name>"
from the “Mysql database”. My requirement is to get an output of the desc table name similar to what we get via MySQL client. I am executing this via Jenkins DSL so that folks can look at the Jenkins console log and don’t log in to the DB server to validate columns etc of DDL statements. Below is the output of an example SQL that just says Custom SQL executed
for reference:
-------------------------------------------------------Output of Jenkins job-------------------------------------------
Skipping auto-registration
[2021-10-06 13:04:13] WARNING [liquibase.hub] Skipping auto-registration
[2021-10-06 13:04:13] FINE [liquibase.changelog] Running Changeset:Desc.sql::version1:xxx
[2021-10-06 13:04:13] FINE [liquibase.executor] Changeset Desc.sql::version1:xxx
[2021-10-06 13:04:13] FINE [liquibase.changelog] Reading ChangeSet: Desc.sql::version1:xxx
[2021-10-06 13:04:13] FINE [liquibase.database] Executing Statement: desc liquibase_testdba3
[2021-10-06 13:04:13] FINE [liquibase.executor] Executing with the 'jdbc' executor
[2021-10-06 13:04:13] INFO [liquibase.changelog] Custom SQL executed
[2021-10-06 13:04:13] INFO [liquibase.changelog] ChangeSet Desc.sql::version1:xxx ran successfully in 8ms
[2021-10-06 13:04:13] FINE [liquibase.executor] Executing with the 'jdbc' executor
[2021-10-06 13:04:13] FINE [liquibase.executor] Executing with the 'jdbc' executor[2021-10-06 13:04:13] FINE [liquibase.executor] 1 row(s) affected
[2021-10-06 13:04:13] FINE [liquibase.executor] Release Database Lock
[2021-10-06 13:04:13] FINE [liquibase.executor] Executing with the 'jdbc' executor
[2021-10-06 13:04:13] INFO [liquibase.lockservice] Successfully released change log lock
Liquibase: Update has been successful.
------------------------------------------------end--------------------------------------------------------------------
Liquibase does not allow the output of “user” SQLs, like SELECT, DESCRIBE, etc.