When changing data types, Liquibase should include NULL/NOT NULL

After some more testing, I found bug in Liquibase (or possibly MySQL, depending on how you look at it).

As you can see here, changing a data type in MySQL (without specifying NULL/NOT NULL) sets it back to Nullable:

    [root@test]# mysql -u root -e "create database TINY_SCHEMA" [root@test]# mysql -u root -e "create table TINY_SCHEMA.TINY_TBL(COL1 BIGINT NOT NULL)" [root@test]# mysql -u root -e "describe TINY_SCHEMA.TINY_TBL" +-------+------------+------+-----+---------+-------+ | Field | Type      | Null | Key | Default | Extra | +-------+------------+------+-----+---------+-------+ | COL1  | bigint(20) | NO  |    | NULL    |      | +-------+------------+------+-----+---------+-------+ [root@test]# mysql -u root -e "alter table TINY_SCHEMA.TINY_TBL modify COL1 DECIMAL(20,0)" [root@test]# mysql -u root -e "describe TINY_SCHEMA.TINY_TBL" +-------+---------------+------+-----+---------+-------+ | Field | Type          | Null | Key | Default | Extra | +-------+---------------+------+-----+---------+-------+ | COL1  | decimal(20,0) | YES  |    | NULL    |      | +-------+---------------+------+-----+---------+-------+

and the SQL that Liquibase executes to change the type doesn’t include “NOT NULL” (just as I’ve run in the example above), even though the only thing that changed in the XML Changelog is the data type, not the nullable=“false” tag.

I had ran into the problem earlier in 2.0 development.  It is a mysql issue only from what I can tell.  I had added a nullable attribute to modifyDataType but then started running into issues with mysql also dropping primary key, autoincrement, and other information about the column on modifyDataType and I didn’t want to start adding all of them. 

I added a warning that should show if you use modifyData with mysql saying that it may be best to use to specify everything needed.  Nullable may be worth adding, though.  I created an issue for it:  http://liquibase.jira.com/browse/CORE-670


I believe I’ve fixed this problem (for MySQL at least), and I should be pushing the code changes back up to you soon.