【发布时间】: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的排序是:
- 20140211_001
- 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>
新的变更集执行顺序会是
- 20140211_001
- 20140212_001
- 20140210_001
【问题讨论】: