Only log one line and don't create a Statement and then decide not to use it

because the migration has already been performed.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2050 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2007-02-18 21:43:08 +00:00
parent 24ac6db16c
commit 7adc165822
@@ -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();
} }