liquibase会在后续更新中更改排序更改吗?

时间:2014-06-12 06:45:37

标签: mysql liquibase

liqibase中的CHANGESET执行是否依赖于它在xml中的位置?例如,如果我有一个如下所示的liquibase脚本

<changeSet id="20140211_001" author="test">
    <createTable tableName="alarm_notification_archive">
        <column name="id" type="bigint">
            <constraints nullable="false" />
        </column>

        <column name="event_timestamp" type="timestamp" defaultValue="0000-00-00 00:00:00">
            <constraints nullable="false" />
        </column>
    </createTable>
</changeSet>

<changeSet id="20140210_001" author="test">
    <sql>ALTER TABLE `notification_archive` ADD COLUMN
        `is_Alarm_Outstanding` BOOLEAN DEFAULT FALSE</sql>
    <rollback>
        <sql>ALTER TABLE notification_archive DROP COLUMN
            is_Alarm_Outstanding
                </sql>
    </rollback>
</changeSet>

我的理解是changeset排序是:

  1. 20140211_001
  2. 20140210_001
  3. 如果我现在在1和2之间添加另一个变更集

    <changeSet id="20140211_001" author="test">
        <createTable tableName="alarm_notification_archive">
            <column name="id" type="bigint">
                <constraints nullable="false" />
            </column>
    
            <column name="event_timestamp" type="timestamp" defaultValue="0000-00-00 00:00:00">
                <constraints nullable="false" />
            </column>
        </createTable>
    </changeSet>
    
    <changeSet id="20140212_001" author="test">
        <sql>ALTER TABLE `notification_archive` ADD COLUMN
            `is_Alarm_Outstanding` BOOLEAN DEFAULT FALSE</sql>
        <rollback>
            <sql>ALTER TABLE alarm_notification_archive DROP COLUMN
                is_Alarm_Outstanding
                </sql>
        </rollback>
    </changeSet>
    
    <changeSet id="20140210_001" author="test">
        <sql>ALTER TABLE `notification_archive` ADD COLUMN
            `is_Alarm_Outstanding` BOOLEAN DEFAULT FALSE</sql>
        <rollback>
            <sql>ALTER TABLE alarm_notification_archive DROP COLUMN
                is_Alarm_Outstanding
                </sql>
        </rollback>
    </changeSet>
    

    新的变更集执行顺序是

    1. 20140211_001
    2. 20140212_001
    3. 20140210_001

2 个答案:

答案 0 :(得分:4)

是的,Liquibase按顺序读取changeSet。请参阅Changeset Documentation

答案 1 :(得分:1)

更明确的是,Liquibase通过文件中的顺序执行变更集

正如here所述,ID内容对执行顺序没有任何影响:

  

id标记仅用作标识符,不指示订单   改变是运行的,甚至不必是整数。