GenerateChangeLog generates invalid XML/SQL for mysql tables with autoincrement and compound PKs

Description

See http://liquibase.org/forum/index.php?topic=314.0

I am trying to migrate the structure generated with the generateChangeLog option but there is a table structure which makes liquibase generate an invalid SQL code for mysql during the migrate phase. Here is the table structure :
Code:

CREATE TABLE `tableName` (
`id` int(10) unsigned NOT NULL auto_increment,
`ts` datetime NOT NULL,
`weather` int(11) default NULL,
PRIMARY KEY (`id`,`ts`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1

As you can see, the primary key contains two columns with one being AUTO_INCREMENT. Here is the xml created by liquibase generateChangeLog option :
Code:

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" ...>
<changeSet author="servaispe (generated)" id="1263484881424-43">
<createTable tableName="tableName">
<column autoIncrement="true" name="id" type="INT UNSIGNED">
<constraints nullable="false"/>
</column>
<column name="ts" type="DATETIME">
<constraints nullable="false"/>
</column>
<column name="weather" type="INT"/>
</createTable>
</changeSet>
<changeSet author="servaispe (generated)" id="1263484881424-55">
<addPrimaryKey columnNames="id, ts" tableName="tableName"/>
</changeSet>
</databaseChangeLog>

Because the primary key has multiple column, the primary key creation is done after the create table and the SQL code for the table creation is the following :
Code:

CREATE TABLE `tableName` (
`id` INT UNSIGNED AUTO_INCREMENT NOT NULL,
`ts` DATETIME NOT NULL,
`weather` INT
)

When this query is executed, the mysql connector throw an Exception with this message : Incorrect table definition; there can be only one auto column and it must be defined as a key.

If the auto_increment primary key is the only column for the pk, the following xml is generated and the generated CREATE TABLE SQL works fine :

Code:

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" ...>
<changeSet author="servaispe (generated)" id="1263484881424-43">
<createTable tableName="tableName">
<column autoIncrement="true" name="id" type="INT UNSIGNED">
<constraints nullable="false" primaryKey="true"/>
</column>
<column name="ts" type="DATETIME">
<constraints nullable="false"/>
</column>
<column name="weather" type="INT"/>
</createTable>
</changeSet>
</databaseChangeLog>

CREATE TABLE `tableName` (
`id` INT UNSIGNED AUTO_INCREMENT NOT NULL,
`ts` DATETIME NOT NULL,
`weather` INT,
PRIMARY KEY (`id`)
)

Environment

None

Status

Assignee

Unassigned

Reporter

Nathan Voxland

Labels

None

Components

Fix versions

Priority

Major