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

**URL:** <https://forum.liquibase.org/t/when-changing-data-types-liquibase-should-include-null-not-null/1417>\
**Category:** Liquibase Development\
**Created:** [July 19, 2010, 8:57pm UTC](https://forum.liquibase.org/t/when-changing-data-types-liquibase-should-include-null-not-null/1417 "2010-07-19T20:57:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cpjust](https://avatars.discourse-cdn.com/v4/letter/c/74df32/32.png) [@cpjust](https://forum.liquibase.org/u/cpjust)\
**Post date:** [July 19, 2010, 8:57pm UTC](https://forum.liquibase.org/t/when-changing-data-types-liquibase-should-include-null-not-null/1417/1 "2010-07-19T20:57:00Z")

</div>

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&nbsp; &nbsp; &nbsp; | Null | Key | Default | Extra | +-------+------------+------+-----+---------+-------+ | COL1&nbsp; | bigint(20) | NO&nbsp; |&nbsp; &nbsp; | NULL&nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; | +-------+------------+------+-----+---------+-------+ [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&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | Null | Key | Default | Extra | +-------+---------------+------+-----+---------+-------+ | COL1&nbsp; | decimal(20,0) | YES&nbsp; |&nbsp; &nbsp; | NULL&nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; | +-------+---------------+------+-----+---------+-------+

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.

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [July 19, 2010, 8:57pm UTC](https://forum.liquibase.org/t/when-changing-data-types-liquibase-should-include-null-not-null/1417/2 "2010-07-19T20:57:00Z")

</div>

I had ran into the problem earlier in 2.0 development.&nbsp; It is a mysql issue only from what I can tell.&nbsp; 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.&nbsp;

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.&nbsp; Nullable may be worth adding, though.&nbsp; I created an issue for it:&nbsp; [http://liquibase.jira.com/browse/CORE-670](http://liquibase.jira.com/browse/CORE-670)

Nathan

---

<div class="post-metadata">

**Author:** ![cpjust](https://avatars.discourse-cdn.com/v4/letter/c/74df32/32.png) [@cpjust](https://forum.liquibase.org/u/cpjust)\
**Post date:** [July 19, 2010, 8:57pm UTC](https://forum.liquibase.org/t/when-changing-data-types-liquibase-should-include-null-not-null/1417/3 "2010-07-19T20:57:00Z")

</div>

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