【发布时间】:2015-10-09 15:13:17
【问题描述】:
我有一个 spring roo hibernate 项目和一个 MySql 数据库,我想使用 liquibase 来管理迁移。
我生成了初始变更日志并执行了 changelogSync 以将所有变更日志标记为已应用。现在当我做了一个差异(没有修改任何东西)时,我希望差异是空的。但是,它删除了所有现有表并创建了具有不同名称的新表。
例如。一个带有 generateChangeLog 的示例变更集:
<changeSet author="author (generated)" id="1437392254522-37">
<createTable tableName="user_roles">
<column name="user" type="BIGINT(19)">
<constraints nullable="false"/>
</column>
<column name="roles" type="BIGINT(19)">
<constraints nullable="false"/>
</column>
</createTable>
</changeSet>
带差异的更改集:
<changeSet author="author (generated)" id="1437395711084-26">
<createTable tableName="User_Role">
<column name="User_id" type="BIGINT">
<constraints nullable="false"/>
</column>
<column name="roles_id" type="BIGINT">
<constraints nullable="false"/>
</column>
</createTable>
</changeSet>
我是否缺少任何设置?
【问题讨论】:
-
这很奇怪。您绝对确定在两个实例中都使用相同的数据库吗?如果只有大小写差异,那将是一回事,但我也看到名称的差异(user_roles 与 User_Role)。这让我觉得发生了一些不寻常的事情。我会使用像 Squirrel SQL 或 MySqlAdmin 这样的外部工具来查看这里是否有多个数据库/模式在起作用。
-
单个数据库。在运行 generateChangeLog 和 diff 之前,我删除了架构并使用 hibernate 的 hbm2ddl 生成基本表。