modifyColumn vs modifyDataType

I am migrating from liquibase 1.9 to 2.0. I noticed that the modifyColumn has been deprecated. In most cases I can use modifyDataType. However, for some columns I want to change the autoincrement flag from true to false. How is the best way to do this in version 2.0? David

There is no good way.

The best that I’ve found is to:

  • add a new column using the element with all the various constraints and whatnot that you want
  • Do UPDATE yourTable SET newColumn = oldColumn
  • Drop the old column with a element
  • Rename newColumn to oldColumn using the refactoring
Extremely ugly and there are all sorts of problems with the update statement given that you might not know what schema yourTable is in.

I’m all ears if someone has a better (portable) idea.


The reason that modifyColumn was removed from 2.0 was because it was too generic and didn’t provide liquibase with enough information on what you were trying to do for it to correctly generate the SQL you need. ModifyDataType is a replacement for much of what people tried to use modifyColumn for, but like you mention it doesn’t cover everything. There is an tag, but not a . 

The trouble is that how you remove an auto-increment column (or if you even can) varies significantly from one database to the next. The best option would be to have a tag that you use in your changelog and will create the correct SQL for the given database, sometimes using the pattern laird listed, sometimes using something more direct if the database supports it. 

With 2.0, you can create a removeAutoIncrement tag that would work for the databases you need (, and if you get far with it it would be nice to have it added to the extension portal so others can use it and we could incorporate it into the core library at some point.