Cope with the new ColumnDefinition.
This commit is contained in:
@@ -151,9 +151,9 @@ public abstract class SchemaMigration extends Modifier
|
|||||||
@Override
|
@Override
|
||||||
protected int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
|
protected int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
|
||||||
log.info("Updating type of '" + _fieldName + "' in " + _tableName);
|
log.info("Updating type of '" + _fieldName + "' in " + _tableName);
|
||||||
return liaison.changeColumn(conn, _tableName, _fieldName, _newColumnDef.getType(),
|
return liaison.changeColumn(conn, _tableName, _fieldName, _newColumnDef.type,
|
||||||
_newColumnDef.isNullable(), _newColumnDef.isUnique(),
|
_newColumnDef.nullable, _newColumnDef.unique,
|
||||||
_newColumnDef.getDefaultValue()) ? 1 : 0;
|
_newColumnDef.defaultValue) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String _fieldName, _columnName;
|
protected String _fieldName, _columnName;
|
||||||
@@ -191,13 +191,13 @@ public abstract class SchemaMigration extends Modifier
|
|||||||
protected int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
|
protected int invoke (Connection conn, DatabaseLiaison liaison) throws SQLException {
|
||||||
// override the default value in the column definition with the one provided
|
// override the default value in the column definition with the one provided
|
||||||
ColumnDefinition defColumnDef = new ColumnDefinition(
|
ColumnDefinition defColumnDef = new ColumnDefinition(
|
||||||
_newColumnDef.getType(), _newColumnDef.isNullable(),
|
_newColumnDef.type, _newColumnDef.nullable,
|
||||||
_newColumnDef.isUnique(), _defaultValue);
|
_newColumnDef.unique, _defaultValue);
|
||||||
// first add the column with the overridden default value
|
// first add the column with the overridden default value
|
||||||
if (liaison.addColumn(conn, _tableName, _fieldName, defColumnDef, true)) {
|
if (liaison.addColumn(conn, _tableName, _fieldName, defColumnDef, true)) {
|
||||||
// then change the column to the permanent default value
|
// then change the column to the permanent default value
|
||||||
liaison.changeColumn(conn, _tableName, _fieldName, _newColumnDef.getType(),
|
liaison.changeColumn(conn, _tableName, _fieldName, _newColumnDef.type,
|
||||||
null, null, _newColumnDef.getDefaultValue());
|
null, null, _newColumnDef.defaultValue);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -791,8 +791,8 @@ public class DepotMarshaller<T extends PersistentRecord>
|
|||||||
// TIMESTAMP columns a value of "0000-00-00 00:00:00" regardless of whether we
|
// TIMESTAMP columns a value of "0000-00-00 00:00:00" regardless of whether we
|
||||||
// explicitly provide a "DEFAULT" value for the column or not, and DATETIME columns
|
// explicitly provide a "DEFAULT" value for the column or not, and DATETIME columns
|
||||||
// cannot accept CURRENT_TIME or NOW() defaults at all.
|
// cannot accept CURRENT_TIME or NOW() defaults at all.
|
||||||
if (!coldef.isNullable() && (coldef.getType().equalsIgnoreCase("timestamp") ||
|
if (!coldef.nullable && (coldef.type.equalsIgnoreCase("timestamp") ||
|
||||||
coldef.getType().equalsIgnoreCase("datetime"))) {
|
coldef.type.equalsIgnoreCase("datetime"))) {
|
||||||
log.info("Assigning current time to " + fmarsh.getColumnName() + ".");
|
log.info("Assigning current time to " + fmarsh.getColumnName() + ".");
|
||||||
ctx.invoke(new Modifier.Simple() {
|
ctx.invoke(new Modifier.Simple() {
|
||||||
@Override protected String createQuery (DatabaseLiaison liaison) {
|
@Override protected String createQuery (DatabaseLiaison liaison) {
|
||||||
|
|||||||
Reference in New Issue
Block a user