Only log one line and don't create a Statement and then decide not to use it
because the migration has already been performed.
This commit is contained in:
@@ -79,15 +79,11 @@ public abstract class EntityMigration extends Modifier
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int invoke (Connection conn) throws SQLException {
|
public int invoke (Connection conn) throws SQLException {
|
||||||
Statement stmt = conn.createStatement();
|
|
||||||
try {
|
|
||||||
log.info("Changing '" + _oldColumnName + "' to '" + _newColumnDef + "' in " +
|
|
||||||
_tableName);
|
|
||||||
|
|
||||||
if (!JDBCUtil.tableContainsColumn(conn, _tableName, _oldColumnName)) {
|
if (!JDBCUtil.tableContainsColumn(conn, _tableName, _oldColumnName)) {
|
||||||
if (JDBCUtil.tableContainsColumn(conn, _tableName, _newColumnName)) {
|
if (JDBCUtil.tableContainsColumn(conn, _tableName, _newColumnName)) {
|
||||||
// we'll accept this inconsistency
|
// we'll accept this inconsistency
|
||||||
log.warning("Column rename appears already performed.");
|
log.warning(_tableName + "." + _oldColumnName + " already renamed to " +
|
||||||
|
_newColumnName + ".");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// but this is not OK
|
// but this is not OK
|
||||||
@@ -101,9 +97,12 @@ public abstract class EntityMigration extends Modifier
|
|||||||
_tableName + " already contains '" + _newColumnName + "'");
|
_tableName + " already contains '" + _newColumnName + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Statement stmt = conn.createStatement();
|
||||||
|
try {
|
||||||
|
log.info("Changing '" + _oldColumnName + "' to '" + _newColumnDef + "' in " +
|
||||||
|
_tableName);
|
||||||
return stmt.executeUpdate("alter table " + _tableName + " change column " +
|
return stmt.executeUpdate("alter table " + _tableName + " change column " +
|
||||||
_oldColumnName + " " + _newColumnDef);
|
_oldColumnName + " " + _newColumnDef);
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
stmt.close();
|
stmt.close();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user