org.liquibase liquibase-core 2.0.5 mysql mysql-connector-java 5.1.15 provided
org.liquibase liquibase-maven-plugin 2.0.1 db.changelogs/my-changelog-master.xml com.mysql.jdbc.Driver jdbc:mysql://localhost:3306/MyDB admin-user ***** update
... liquibase.changelog db.changelogs/db.changelog-master.xml liquibase.datasource java:jboss/datasources/LiquibaseDS
liquibase.integration.servlet.LiquibaseServletListener …
<?xml version="1.0" encoding="UTF-8"?> <databaseChangeLog xmlns=“http://www.liquibase.org/xml/ns/dbchangelog” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=“http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd”>
<?xml version="1.0" encoding="UTF-8"?> <databaseChangeLog xmlns=“http://www.liquibase.org/xml/ns/dbchangelog” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=“http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd”> <addUniqueConstraint columnNames=“CODE,DESCRIPTION” constraintName=“CODE_UK” tableName=“TEST_TABLE”/> <addForeignKeyConstraint baseColumnNames=“TEST_CODE” baseTableName=“ANOTHER_TEST_TABLE” constraintName=“TEST_OTHER_FK” referencedColumnNames=“CODE” referencedTableName=“TEST_TABLE”/>
<?xml version="1.0" encoding="UTF-8"?> <databaseChangeLog xmlns=“http://www.liquibase.org/xml/ns/dbchangelog” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=“http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd”> <loadData file=“db.changelogs/mydata.csv” schemaName=“MyDB” quotchar="’" tableName=“TEST_TABLE”/>
CODE,DESCRIPTION,VALUE ‘T01’,‘Not specified’,‘FOO’ ‘T02’,‘Wrongly specified’,‘BAR’ ‘T03’,‘Correct’,‘FOO-BAR’
We see our tables with the data are being created. We also see two more tables: ‘DATABASECHANGELOG’ and ‘DATABASECHANGELOGLOCK’. These are used by Liquibase to determine the state of the database. If I deploy the WAR file with a datasource against this database Liquibase will see that the scripts already have run and won’t execute them again. If I remove the tables however the scripts will be executed as it was against a new database. As you can see this can simplify the deployment of new releases of your software, at least the database part.