Hello,
I have been playing with liquibase maven plugin and it works great.
I have defined a db.changelog.xml with 2 changesets.
I am able to run maven plugin to recreate database by running changeset 1, for instance.
Now, I am trying to achieve the autoupdate of database when deploying my web-app.
For this, I have added the spring bean:
- <bean id="liquibase" class="liquibase.integration.spring.SpringLiquibase">
- <property name="dataSource" ref="dataSource" />
- <property name="changeLog" value="classpath:db/db.changelog.xml" />
- <property name="defaultSchema" value="mydb" />
- </bean>
When I run my web-app, liquibase tries to run changeset 1, even though it is registered in databasechangelog table. I was expecting the spring bean would automatically skip changeset 1 and run only changeset 2, but I get a migration exception. What am I missing?
- INFO 31/01/12 15:48:liquibase: Successfully acquired change log lock
- WARNING 31/01/12 15:48:liquibase: Current XML parsers seems to not support EntityResolver2. External entities won't be correctly loaded
- INFO 31/01/12 15:48:liquibase: Reading from `vetisigma`.`DATABASECHANGELOG`
- INFO 31/01/12 15:48:liquibase: Reading from `vetisigma`.`DATABASECHANGELOG`
- SEVERE 31/01/12 15:48:liquibase: Change Set classpath:db/db.changelog.xml::1::jg (generated) failed. Error: Error executing SQL CREATE TABLE `mydb`.`admin_route` (`id` BIGINT AUTO_INCREMENT NOT NULL, `name` VARCHAR(50) NOT NULL, CONSTRAINT `PK_ADMIN_ROU
- TE` PRIMARY KEY (`id`)): Table 'admin_route' already exists
- liquibase.exception.DatabaseException: Error executing SQL CREATE TABLE `mydb`.`admin_route` (`id` BIGINT AUTO_INCREMENT NOT NULL, `name` VARCHAR(50) NOT NULL, CONSTRAINT `PK_ADMIN_ROUTE` PRIMARY KEY (`id`)): Table 'admin_route' already exists
- at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:62)
- at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:104)
My changeset file:
- <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">
- <changeSet author="jg (generated)" id="1">
- <createTable tableName="admin_route">
- <column autoIncrement="true" name="id" type="BIGINT">
- <constraints nullable="false" primaryKey="true"/>
- </column>
- <column name="name" type="VARCHAR(50)">
- <constraints nullable="false"/>
- </column>
- </createTable>
- ...
- </changeSet>
- <changeSet author="jgarcia (generated)" id="2">
- ...
- </changeSet>
- </databaseChangeLog>
-