我阅读了 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/