2016-03-25 79 views
1

我可以創建分區表所示:如何創建分區表liquibase

CREATE TABLE person(
    id INT NOT NULL, 
    NAME VARCHAR(30), 
    borned TIMESTAMP) 
PARTITION BY RANGE (UNIX_TIMESTAMP(borned)) (
    PARTITION p0 VALUES LESS THAN (UNIX_TIMESTAMP('2000-01-01 00:00:00')), 
    PARTITION p1 VALUES LESS THAN (MAXVALUE)); 
使用liquibase標籤

?我的意思不是自定義<sql>而是<createTable>

回答

0

不是沒有編寫自己的自定義更改標籤(如Datical已完成)。

+0

感謝,但它不是在3年項目中遷移到其他數據庫遷移工具的原因) –

2

自1.9:您可以使用modifySql(根據updateSql目標)要追加到createTable輸出

<changeSet author="StackOverflow" id="C0FE77AA-5517-11E7-8CAD-224C16886A7C"> 
    <createTable tableName="test"> 
     <column name="id" type="INT"> 
      <constraints nullable="false"/> 
     </column> 
     <column name="NAME" type="VARCHAR(30)"/> 
     <column name="borned" type="TIMESTAMP"/> 
    </createTable> 
    <modifySql> 
     <append value=" PARTITION BY RANGE (UNIX_TIMESTAMP(borned)) (
PARTITION p0 VALUES LESS THAN (UNIX_TIMESTAMP('2000-01-01 00:00:00')), 
PARTITION p1 VALUES LESS THAN (MAXVALUE))"/> 
    </modifySql> 
</changeSet> 

Liquibase輸出以下SQL:

CREATE TABLE db.test (id INT NOT NULL, NAME VARCHAR(30) NULL, borned timestamp NULL) PARTITION BY RANGE (UNIX_TIMESTAMP(borned)) ( PARTITION p0 VALUES LESS THAN (UNIX_TIMESTAMP('2000-01-01 00:00:00')),  PARTITION p1 VALUES LESS THAN (MAXVALUE));