mysql> create database test1 default character set utf8;
Query OK, 1 row affected (0.00 sec)
mysql> create database test2 default character set utf8;
Query OK, 1 row affected (0.00 sec)
mysql> use test1
Database changed
mysql> create table a (id int(10), c int(10), v int(10), b int(10),
key cvb (c,v,b));
Query OK, 0 rows affected (0.00 sec)
mysql> use test2
Database changed
mysql> create table a (id int(10), c int(10), v int(10), b
int(10), key cvb (v,b));
Query OK, 0 rows affected (0.00 sec)
Liquibase Version: 3.2.2
Create diffChangeLog:
root@080c21576872:/opt# ./liquibase --driver=com.mysql.jdbc.Driver
--classpath=/usr/share/java/mysql-connector-java-5.1.10.jar
--url="jdbc:mysql://localhost/test2" --username=root
--password='' diffChangeLog
--referenceUrl="jdbc:mysql://localhost/test1"
--referenceUsername=root --referencePassword='' > diff.xml
Liquibase 'diffChangeLog' Successful
root@080c21576872:/opt# cat diff.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog
xmlns="
http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="
http://www.liquibase.org/xml/ns/dbchangelog-ext"
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.2.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet author="root (generated)" id="1414522888481-1">
<createIndex
indexName="cvb" tableName="a" unique="false">
<column name="c"/>
<column name="v"/>
<column name="b"/>
</createIndex>
</changeSet>
<changeSet author="root (generated)" id="1414522888481-2">
<dropIndex
indexName="cvb" tableName="a"/>
</changeSet>
</databaseChangeLog>
Update test2:
root@080c21576872:/opt# ./liquibase --driver=com.mysql.jdbc.Driver
--classpath=/usr/share/java/mysql-connector-java-5.1.10.jar
--url="jdbc:mysql://localhost/test2" --username=root
--password='' --changeLogFile=diff.xml update
Unexpected error running Liquibase: Error executing SQL CREATE INDEX cvb
ON test2.a(c, v, b): Duplicate key name 'cvb'
The sequence of actions in the file is broken.
modify file diff.xml:
root@080c21576872:/opt# cat diff.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog
xmlns="
http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="
http://www.liquibase.org/xml/ns/dbchangelog-ext"
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.2.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet author="root (generated)" id="1414522888481-2">
<dropIndex
indexName="cvb" tableName="a"/>
</changeSet>
<changeSet author="root (generated)" id="1414522888481-1">
<createIndex
indexName="cvb" tableName="a" unique="false">
<column name="c"/>
<column name="v"/>
<column name="b"/>
</createIndex>
</changeSet>
</databaseChangeLog>
root@080c21576872:/opt# ./liquibase --driver=com.mysql.jdbc.Driver
--classpath=/usr/share/java/mysql-connector-java-5.1.10.jar
--url="jdbc:mysql://localhost/test2" --username=root
--password='' --changeLogFile=diff.xml update
Liquibase Update Successful
How to generate the correct file
?