Hi everybody,
Today i finally changed to Liquibase 2.0 Rc5.
After I created in my small MySQL database a table with name “news” and attributes “ID” and “author”. <-- Tagged with Version 1
After that I did some changes to the main database:
Added new Table with name “newnews” and the attributes “ID” and “adress”, <–Tagged with Version 2
And now i tried to run a rollback with this method:

    public static void rollbackChanges() throws LiquibaseException { ResourceAccessor resAcc = new FileSystemResourceAccessor(); DatabaseFactory databaseFactory = DatabaseFactory.getInstance(); Database database = null; try { database = databaseFactory.findCorrectDatabaseImplementation(connect()); } catch ( JDBCException e) { e.printStackTrace(); } Liquibase liquibase = new Liquibase(changelog, resAcc, database); try { liquibase.rollback("Version 1", ""); } catch (LiquibaseException e ) { System.out.println("Rollback failed... " + e); e.printStackTrace(); } }
and i get the message:
    Rollback failed... liquibase.exception.RollbackFailedException: liquibase.exception.DatabaseException: Error executing SQL DROP INDEX `PRIMARY` ON `newnews` liquibase.exception.RollbackFailedException: liquibase.exception.DatabaseException: Error executing SQL DROP INDEX `PRIMARY` ON `newnews` at liquibase.changelog.ChangeSet.rolback( at liquibase.changelog.visitor.RollbackVisitor.visit( at at liquibase.Liquibase.rollback( at liq.hibernate.DBTest3.rollbackChanges( at liq.hibernate.DBTest3.main( Caused by: liquibase.exception.DatabaseException: Error executing SQL DROP INDEX `PRIMARY` ON `newnews` at liquibase.executor.jvm.JdbcExecutor.execute( at liquibase.executor.jvm.JdbcExecutor.execute( at liquibase.database.AbstractDatabase.execute( at liquibase.database.AbstractDatabase.executeRollbackStatements( at liquibase.changelog.ChangeSet.rolback( ... 5 more Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Incorrect table definition; there can be only one auto column and it must be defined as a key at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance( at sun.reflect.DelegatingConstructorAccessorImpl.newInstance( at java.lang.reflect.Constructor.newInstance( at com.mysql.jdbc.Util.handleNewInstance( at com.mysql.jdbc.Util.getInstance( at com.mysql.jdbc.SQLError.createSQLException( at com.mysql.jdbc.MysqlIO.checkErrorPacket( at com.mysql.jdbc.MysqlIO.checkErrorPacket( at com.mysql.jdbc.MysqlIO.sendCommand( at com.mysql.jdbc.MysqlIO.sqlQueryDirect( at com.mysql.jdbc.ConnectionImpl.execSQL( at com.mysql.jdbc.ConnectionImpl.execSQL( at com.mysql.jdbc.StatementImpl.execute( at com.mysql.jdbc.StatementImpl.execute( at liquibase.executor.jvm.JdbcExecutor$1ExecuteStatementCallback.doInStatement( at liquibase.executor.jvm.JdbcExecutor.execute( ... 9 more
is it a problem on my side, that i did something wrong or is it a error in the Syntax of MySQL? Thanks for reading and answering :)

It is an issue with mysql that we do not attempt to work around.  It appears that you have ID defined as an auto-increment primary key.  Dropping the primary key just attempts to drop the primary key which mysql does not allow because it is still autoincrement and an autoincrement column needs to be a primary key.

You’ll have to drop the auto-increment first.


Thank you for your answer :-),
but anyway… how can i tell that to liquibase cause, as you see in my small method i am calling the changelog from Version 1 to Version 2, which looks like:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>" xmlns:xsi="" xsi:schemaLocation="">                                                                                                                                            
These are the changes from "Version 1" to "Version 2". And i want fully organize the database with liquibase in Java. So i don't want to edit the changelog via xml. Is it anyway possible with this changelog, to rollback the changes?

I see.  It looks like the generateChangeLog is creating the primary key index in the generateChangeLog along with the normal primary key.  This was due to some attempts at solving the a problem with how different datababase types handle creating indexes automatically for primary and foreign keys.  It wasn’t completed and will be worked on more for 2.1.  This should be solved in RC6.