My Environment:
database change log xml
<?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 updateSql
command, I see the following sql being generated
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 that the columns would be SMALLINT UNSIGNED
. Is there something that I am doing wrong?
I implemented CORE-2300 Unsigned Int / Bigint cannot be created that fixes this issue. It has been merged to the master branch. If you can use a -SNAPSHOT version based on master then you could get the fix before the 3.4.0 release, which I suspect will be in the next few months.
If you're 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 could 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 resultant distribution zip file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With