gpt4 book ai didi

Liquibase Stored Proc 的管理

转载 作者:行者123 更新时间:2023-12-04 01:52:10 24 4
gpt4 key购买 nike

我阅读了 liquibase 的最佳实践,专门用于管理存储过程:

Managing Stored Procedures: Try to maintain separate changelog for Stored Procedures and use runOnChange=”true”. This flag forces LiquiBase to check if the changeset was modified. If so, liquibase executes the change again.



“为存储过程维护单独的变更日志”是什么意思?

我通常有一个链接到版本的变更日志目录。每个变更日志文件都包含在 master.xml 中.

遵循他们的建议时目录结构是什么?

最佳答案

我们所做的是这样的:

\---liquibase
| changelog.xml
| procedures.xml
|
+---procedures
procedure_one.sql
procedure_two.sql
changelog.xml仅包括 procedures.xml .内 procedures.xml然后我们有这样的事情:
<changeSet author="arthur" id="1" runOnChange="true" runInTransaction="true">
<sqlFile path="procedures/procedure_one.sql"
encoding="UTF-8"
relativeToChangelogFile="true"
endDelimiter=";"
splitStatements="true"/>

</changeSet>

<changeSet author="arthur" id="2" runOnChange="true" runInTransaction="true">
<sqlFile path="procedures/procedure_two.sql"
encoding="UTF-8"
relativeToChangelogFile="true"
endDelimiter=";"
splitStatements="true"/>

</changeSet>

当然 runInTransaction="true"仅当您的 DBMS 支持事务性 DDL 时才有意义。

过程的每个 SQL 脚本都是自包含的,并使用 create or replace 重新创建过程。 .对于不支持的 DBMS create or replace我们通常做一个(有条件的) drop procedure; create procedure ...在那里。

通过显式包含文件(而不是使用 includeAll),我们可以控制过程和函数的创建顺序(如果使用另一个很重要)。

如果添加新过程,则向 procedures.xml 添加新 SQL 脚本和新更改集。

关于Liquibase Stored Proc 的管理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39989749/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com