java - How to roll back a database change with Liquibase using classpath -
my application using liquibase manage database changes. sets liquibase so:
@bean(name = "liquibase") public springliquibase liquibasedata() { final springliquibase liquibase = new springliquibase(); liquibase.setdatasource(datasource); liquibase.setchangelog("classpath:/db/changelog/db.changelog-master.xml"); return liquibase; }
it has single changeset. when changeset gets applied running application, record inserted databasechangelog
expected filename
of classpath:/db/changelog/0.0.1/db.changelog.xml
when execute liquibase rollbackcount 1
, response liquibase rollback successful
, change did not rolled back.
after manually rolling change (deleting table created changeset), liquibase update
. update successful, filename
db/changelog/0.0.1/db.changelog.xml
. execute liquibase rollbackcount 1
, , change rolled expected.
this liquibase.properties
:
driver: oracle.jdbc.driver.oracledriver classpath: ../../../../../client-ui/build/libs/client-ui.war url: jdbc:oracle:thin:@localhost:1521/orcl username: the-username password: the-password changelogfile: classpath:/db/changelog/db.changelog-master.xml
the crux of problem seems filename
different when changeset applied application versus command line. how configure command line parameters create databasechangelog
record same filename
application creates?
yes, problem filename different. spring includes classpath: in url liquibase uses. there code in liquibase try handle "sometimes there classpath:" prefix, sounds not handled correctly in rollback logic.
there have been improvements how classpath prefix handled in recent versions, have tried liquibase 3.4.0?
otherwise, liquibase update through spring should work correctly or without classpath prefix, if fix filename field should good. update databasechangelog set filename = substr(filename, 10) filename 'classpath:%'
if using mysql. put runalways=true changeset @ bottom of changelog file have automatically clean paths on each update.
Comments
Post a Comment