Liquibase does not create unsigned columns

My environment:

  • java: 1.8.0_20, 64 bit
  • educational base: 3.3.1
  • mysql: 5.5.34
  • Mysql connector: mysql-connector-java-5.1.34-bin.jar
  • mysql driver: com.mysql.jdbc.Driver
  • mysql connection string: jdbc: mysql: // localhost / my_db
  • Mysql user: root user
  • os: windows 7 64

xml database change log

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" 
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.3.xsd">

<changeSet author="jbenton" id="create my_test_tbl table">
   <sql> SET storage_engine=MYISAM; </sql>
    <createTable tableName="my_test_tbl">
        <column autoIncrement="true" name="my_test_tbl_id" type="INT UNSIGNED">
            <constraints primaryKey="true"/>
        </column>
        <column defaultValueNumeric="0" name="col_smallint" type="SMALLINT">
            <constraints nullable="false"/>
        </column>
        <column defaultValueNumeric="0" name="col_smallint_unsigned" type="SMALLINT UNSIGNED"/>
        <column defaultValueNumeric="0" name="col_smallint_unsigned_not_null" type="SMALLINT UNSIGNED">
            <constraints nullable="false"/>
        </column>
    </createTable>
</changeSet>
</databaseChangeLog>

      

Using the command updateSql

I see the following generated sql

CREATE TABLE my_db.my_test_tbl (
   my_test_tbl_id INT AUTO_INCREMENT NOT NULL, 
  col_smallint SMALLINT DEFAULT 0 NOT NULL, 
  col_smallint_unsigned SMALLINT DEFAULT 0 NULL, 
  col_smallint_unsigned_not_null SMALLINT DEFAULT 0 NOT NULL, 
  CONSTRAINT PK_MY_TEST_TBL PRIMARY KEY (my_test_tbl_id));

      

My goal is for the columns to be SMALLINT UNSIGNED

. Is there something I am doing wrong?

+3


source to share


2 answers


I have implemented CORE-2300 Unsigned Int / Bigint Cannot Be Created , which fixes this issue. It was merged into the main branch. If you can use the wizard-based version of -SNAPSHOT, you can get a pre-3.4.0 patch that I suspect will be in the next few months.

If you are using Maven:

<dependency>
    <groupId>org.liquibase</groupId>
    <artifactId>liquibase-core</artifactId>
    <version>3.4.0-SNAPSHOT</version>
</dependency>

      

Or download it from the build server:

https://liquibase.jira.com/builds/browse/CORE-LB-90/artifact

liquibase-3.4.0-SNAPSHOT-bin.zip



Or if you want to use 3.3.x you can create your own 3.3.4-SNAPSHOT

$ git clone https://github.com/liquibase/liquibase.git
$ cd liquibase
$ git checkout 3.3.x
$ git cherry-pick 5bf8fc591477587c3f61c876e91011d0b8a6d362
$ git status
$ # resolve the merge conflicts
$ vi liquibase-core/src/main/java/liquibase/datatype/core/*IntType.java
$ git add '*.java'
$ git cherry-pick --continue
$ mvn clean verify

      

Then update your POM:

<dependency>
    <groupId>org.liquibase</groupId>
    <artifactId>liquibase-core</artifactId>
    <version>3.3.4-SNAPSHOT</version>
</dependency>

      

or use the resulting distribution zip file.

+1


source


I had the same problem. This seems to be a bug in the current Liquibase implementation that seems to be fixed since 3.4.0 (see https://liquibase.jira.com/browse/CORE-2300 ). I've tried committing the issue related commits ( https://github.com/liquibase/liquibase/commit/5bf8fc591477587c3f61c876e91011d0b8a6d362 ) on 3.3.2. This fixes an unsigned issue, but creating auto-incrementing columns of unsigned types failed.



In the end I used version 3.0.7 which seems to be the last one without this problem. Works flawlessly so far.

0


source







All Articles