I seemed to be getting an exception when trying to upgrade/migrate DB’s. I seems to work until it get to a certain row i.e. 48586. I retested as though data was corrupted but same thing happen again. What the mysql is trying to do is drop the current primary key for table Logs, then add new primary keys IP, logId, logTime.
SEVERE 10/15/12 2:27 PM:liquibase: Error executing SQL ALTER TABLE `Logs` ADD PRIMARY KEY (`IP`, `logId`, `logTime`)
java.sql.SQLException: Data truncated for column 'logTime' at row 48586
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2619)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2569)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:824)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:667)
at liquibase.executor.jvm.JdbcExecutor$1ExecuteStatementCallback.doInStatement(JdbcExecutor.java:92)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:105)
at liquibase.database.AbstractDatabase.execute(AbstractDatabase.java:1014)
at liquibase.database.AbstractDatabase.executeStatements(AbstractDatabase.java:998)
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:317)
at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:27)
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:58)
at liquibase.Liquibase.update(Liquibase.java:113)
at liquibase.integration.commandline.Main.doMigration(Main.java:684)
at liquibase.integration.commandline.Main.main(Main.java:116)
As documented under MySQL Glossary:
Under
CREATE TABLESyntax, then manual explains:It would appear that your
logTimecolumn permitted (and contained)NULLvalues; attempting to create aPRIMARY KEYover it caused the column to be silently declared asNOT NULL, thereby “truncating” anyNULLvalues to the column’s default value: the error is similar toER_WARN_NULL_TO_NOTNULL.