liquibase 没有创建未签名的列

Jef*_*ton 5 mysql liquibase

我的环境:

  • java: 1.8.0_20, 64 位
  • liquibase:3.3.1
  • mysql: 5.5.34
  • mysql 连接器:mysql-connector-java-5.1.34-bin.jar
  • mysql 驱动程序:com.mysql.jdbc.Driver
  • mysql 连接字符串:jdbc:mysql://localhost/my_db
  • mysql用户:root用户
  • 操作系统:Windows 7 64

数据库更改日志 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>
Run Code Online (Sandbox Code Playgroud)

使用该updateSql命令,我看到正在生成以下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));
Run Code Online (Sandbox Code Playgroud)

我的目标是列将是SMALLINT UNSIGNED. 有什么我做错了吗?

小智 0

我有同样的问题。这似乎是 liquibase 当前实现中的一个错误,似乎已在 3.4.0 中得到修复(参见https://liquibase.jira.com/browse/CORE-2300)。我尝试在 3.3.2 上实现附加到该问题的提交(https://github.com/liquibase/liquibase/commit/5bf8fc591477587c3f61c876e91011d0b8a6d362)。这解决了无符号问题,但创建具有无符号类型自动增量的列失败。

最后我使用了3.0.7版本,这似乎是最后一个没有这个问题的版本。到目前为止工作完美。