I've already tried liquibase 3.0 beta with Spring( btw It didn't work with 2.0 ). It went well.
Now I'm testing it with Ant with the same database and changelog, after rollbacked all the changes and dropped table DATABASECHANGELOG and DATABASECHANGELOGLOCK.
The problem is liquibase logged all the changesets in table DATABASECHANGELOG , which means there isn't any error in my config , but It didn't commit the changes to the database.
Here is my changelog.xml file:
<?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-3.0.xsd">
<preConditions>
<dbms type="mysql"/>
</preConditions>
<changeSet id="1" author="bob" runAlways="true">
<createTable tableName="department">
<column name="id" type="int">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="name" type="varchar(50)">
<constraints nullable="false"/>
</column>
<column name="active" type="boolean" defaultValueBoolean="true"/>
</createTable>
</changeSet>
<changeSet id="2" author="roger" runAlways="true">
<comment>test add column</comment>
<addColumn tableName="department">
<column name="header" type="varchar(8)"/>
</addColumn>
</changeSet>
<changeSet id="3" author="gabriel" runAlways="true">
<createTable tableName="records">
<column name="id" type="int" autoIncrement="true">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="title" type="varchar(50)"/>
</createTable>
</changeSet>
<changeSet id="4" author="gabriel" context="test" runAlways="true">
<insert tableName="records">
<column name="title" value="Liquibase 0.8 Released"/>
</insert>
<insert tableName="records">
<column name="title" value="Liquibase 0.9 Released"/>
</insert>
</changeSet>
<changeSet id="6" author="nvoxland" runAlways="true">
<comment>test update eam_company</comment>
<sql>update eam_company set companyName='haha' where companyId=15</sql>
</changeSet>
</databaseChangeLog>
Ant build.xml file:
<?xml version="1.0" encoding="utf-8"?>
<project name="ncpsys_v2" default="all">
<!-- define time stamp -->
<tstamp>
<format property="current.time" pattern="yyyy_MM_dd_HH_mm_ss"/>
</tstamp>
<!-- define varibles and path -->
<property file="liquibaseconf.properties"/>
<path id="ant.classpath">
<fileset dir="${ant.home}">
<include name="**/*.jar"/>
</fileset>
</path>
<target name="sync-database">
<fail unless="db.changelog.file">db.changelog.file not set</fail>
<fail unless="database.url">database.url not set</fail>
<fail unless="database.username">database.username not set</fail>
<fail unless="database.password">database.password not set</fail>
<taskdef resource="liquibasetasks.properties">
<classpath refid="ant.classpath"/>
</taskdef>
<changeLogSync changeLogFile="${db.changelog.file}" driver="${database.driver}" url="${database.url}" username="${database.username}" password="${database.password}" promptOnNonLocalDatabase="true" defaultSchemaName="root" classpathref="ant.classpath">
</changeLogSync>
</target>
<target name="all" depends="sync-database"/>
</project>
liquibasetasks.properties file
local.dir=.
#gwt.home=E:/work/libaray/gwt-2.3.0
jdk.home.1.6=C:/Program Files/Java/jdk1.6.0_10
ant_home=D:/software/apache-ant-1.8.3
tomcat.home=C:/Program Files/Apache Software Foundation/apache-tomcat-6.0.36
#liquibase config
database.driver=com.mysql.jdbc.Driver
database.url=jdbc:mysql://localhost:3306/ncpsys_v2?useUnicode=true&characterEncoding=UTF-8
database.username=root
database.password=1234
db.changelog.file=changelog.xml
And I run the Ant task, liquibase created table DATABASECHANGELOG and DATABASECHANGELOGLOCK for me, and inserted logs in DATABASECHANGELOG .
my build log:
sync-database:
[changeLogSync] INFO 13-4-2 下午1:22:liquibase: Successfully acquired change log lock
[changeLogSync] INFO 13-4-2 下午1:22:liquibase: Creating database history table with name: `ncpsys_v2`.`DATABASECHANGELOG`
[changeLogSync] INFO 13-4-2 下午1:22:liquibase: Reading from `ncpsys_v2`.`DATABASECHANGELOG`
[changeLogSync] INFO 13-4-2 下午1:22:liquibase: Reading from `ncpsys_v2`.`DATABASECHANGELOG`
[changeLogSync] INFO 13-4-2 下午1:22:liquibase: Successfully released change log lock
all:
BUILD SUCCESSFUL
Total time: 2 seconds
but the change didn't happened in the database. I didn't see the table RECORDS and DEPARTMENT been created and inserted with data. The update sql didn't apply neither.
Is there anything I did wrong ? Or is there a bug that haven't been fixed under version 3.0beta1 (oh .. I also try beta2, didn't work, and I got a chinese garbled character problem )
I posted this question on liquibase forum and got no answer, so I come to you guys.
Please, help me! I got all confused.