【问题标题】:Does liquibase changeset ordering change on subsequent updates?liquibase 变更集的顺序是否会在后续更新中发生变化?
【发布时间】:2018-04-23 21:27:05
【问题描述】:

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

如果我现在在 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

【问题讨论】:

    标签: mysql liquibase


    【解决方案1】:

    是的,Liquibase 会按顺序读取变更集。见Changeset Documentation

    【讨论】:

      【解决方案2】:

      为了更清楚一点,Liquibase 按文件中的顺序执行变更集。

      here解释,ID内容对执行顺序没有任何影响:

      id标签只用作标识符,它不指导订单 运行更改,甚至不必是整数。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-06-17
        • 2018-01-01
        • 2015-11-25
        • 2013-11-14
        • 1970-01-01
        • 2014-05-20
        • 2019-04-29
        • 1970-01-01
        相关资源
        最近更新 更多