liquibase.exception.RollbackFailedException

Hi everybody,
Today i finally changed to Liquibase 2.0 Rc5.
Story:
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(ChangeSet.java:335) at liquibase.changelog.visitor.RollbackVisitor.visit(RollbackVisitor.java:23) at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:39) at liquibase.Liquibase.rollback(Liquibase.java:294) at liq.hibernate.DBTest3.rollbackChanges(DBTest3.java:138) at liq.hibernate.DBTest3.main(DBTest3.java:154) Caused by: liquibase.exception.DatabaseException: Error executing SQL DROP INDEX `PRIMARY` ON `newnews` at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:62) at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:97) at liquibase.database.AbstractDatabase.execute(AbstractDatabase.java:981) at liquibase.database.AbstractDatabase.executeRollbackStatements(AbstractDatabase.java:1005) at liquibase.changelog.ChangeSet.rolback(ChangeSet.java:322) ... 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(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at com.mysql.jdbc.Util.handleNewInstance(Util.java:406) at com.mysql.jdbc.Util.getInstance(Util.java:381) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1051) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3563) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3495) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2113) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2687) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2616) at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:782) at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:625) at liquibase.executor.jvm.JdbcExecutor$1ExecuteStatementCallback.doInStatement(JdbcExecutor.java:88) at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55) ... 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.

Nathan

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"?> 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">                                                                                                                                            
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.

Nathan