Wrong datatype with renameColumn


In the project I am working on, we are running MSSQL Server in the actual environments, but we also the possibilities of using a local launcher during development, with MySQL as a database provider.

When defining a numeric column type, we do this:

<createTable name="SomeTable">
<column name="id" type="numeric(19,0)" [...]

<modifySql dbms="mysql">
<replace replace="NUMBER(19,0)" with="bigint(20)"/>

This works alright (apart from the quirk of having to override the type as NUMBER when we define it as numeric).

But, when trying to rename a column, things get mucked up:

<renameColumn tableName="SomeTable" oldColumnName="OldName" newColumnName="NewName"

<replace replace="NUMBER(19,0)" with="bigint(20)"/>

This results in a the column of type DECIMAL(19, 0) in MySQL, which of course makes things fail, so we have to add another construct that resets the datatype to what it correctly should be, (like <modifyDataType>)

Curiously, adding a not-null constraint sets the datatype back to the correct one, so having

<addNotNullConstraint tableName="SomeTable" columnName="NewName" columnDataType="numeric(19,0)"/>

in the above script would result in the proper datatype (not important, but hid the error on one occation..)


Windows 7, MySQL


Nathan Voxland
December 9, 2013, 9:04 PM

This is working fine in 3.0.8. modifySql just does a "replace" and so case and spacing matters. With 3.x the numeric(19,0) is coming thorough as "NUMBER(19, 0)" so you need to use that in modifySql.

Running updateSql helps for seeing what will work for replacement



Torbjørn Skyberg Knutsen

Fix versions

Affects versions