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();
}
}
- 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