使用 Liquibase 创建过程
I'm evaluating liquibase for a project starting today.
Has anybody used it to create procedures, functions, basically all of the plsql stuff?
If not, is it possible to write embedded sql code in the xml files?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
liquibase 中有一个内置的 createProcedure 标签用于管理过程。最好的方法通常是将 或 标签与 runOnChange 结合起来,这样当且仅当您更新定义时 liquibase 才会更新您的过程。这样,您就可以随着时间的推移在变更日志 xml 文件之间进行比较,并查看过程如何变化。
使用 sqlFile 标签来引用每个存储过程的文件也很流行,或者,就像你说的,你可以使用 sql 标签来内联自定义sql。
There is a built-in createProcedure tag in liquibase for managing procedures. The best approach is usually to combine the or tags with runOnChange so liquibase will update your procedure when and only when you update the definition. That way you can do diffs between your changelog xml files over time and see how the procedure has changed.
Using the sqlFile tag to reference file per stored-proc is also popular, or, like you said, you can use the sql tag to inline custom sql.
我在尝试对存储过程、触发器和函数使用 sql 标签时遇到了问题,但就我而言,这些问题显然是 MySQL JDBC 驱动程序的问题,而不是 Liquibase 本身的问题。我采用的做法是按照 Nathan 的建议使用 sqlFile 重构,然后在与变更日志相同的项目中控制 SP/触发器/函数代码,并在源代码系统中对其进行版本控制。这使您可以像管理真正的源代码一样管理 SP/任何代码。
在包含 sqlFile 重构的变更集中设置 runOnChange="true" 至关重要。正是这个开关(谢谢你,Nathan)实现了过程数据库代码的真正源代码控制。
I've encountered issues with trying the use the sql tag for stored procedures, triggers, and functions, but in my case these were provably issues with the MySQL JDBC driver, and not Liquibase itself. The practice I've settled into is to use the sqlFile refactoring as Nathan suggests, then to control the SP/trigger/function code in the same project as the changelog, versioned in the source code system along with it. This lets you manage the SP/whatever code just like it was real source code.
Setting runOnChange="true" in the changeSet containing the sqlFile refactoring is essential. It is this switch (thank you, Nathan) that enables real source control of procedural database code.
虽然我没有将 liquibase 用于存储过程,但我对 Liquibase 对于更通用的操作有一些经验。
可以编写自定义 sql,嵌入 xml 文件中或从外部文件引用。
While I haven't used liquibase for stored procedures, I have some experience of Liquibase for more generic operations.
It is possible to write custom sql, either embedded in the xml file or referenced from an external file.