Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dealing with liquibase upgrade that changed MySQL boolean type from tinyint to bit

Tags:

liquibase

I'm trying to upgrade Liquibase from 2.0.5 to 3.2.2. Liquibase 3.2.2 has changed the boolean type implementation for MySQL from tinytint(1) to bit(1). This breaks a lot of our historical changesets, e.g. in places where we set the default like so: default="1" (which fails with error Data truncation: Data too long for column in MySQL 5.6.16).

Rather than rewrite/fix gobs of changeset history, I'm looking for an easier way to deal with it so we can upgrade. I'm not opposed to telling Liquibase to continue to use tinyint(1) for mysql. I see notes in the user forum on extending liquibase.database.typeconversion.core.MySQLTypeConverter to accomplish it, but that mechanism does not appear to be available in 3.2.2.

Any idea how I tell Liquibase 3.2.2 to continue to use tinyint(1)? Failing that, any other ideas on how deal with this without rewriting changeset history?

like image 852
alba lion Avatar asked Sep 16 '14 16:09

alba lion


1 Answers

With 3.2.2, the TypeConverterLogic has moved to type-specific classes. So you can override liquibase.datatype.core.BooleanType and the toDatabaseDataType() method to return TINYINT(1) instead of BIT(1)

like image 200
Nathan Voxland Avatar answered Oct 12 '22 07:10

Nathan Voxland