Pre and Post 迁移 - 调用外部脚本 - liquibase
Pre and Post Migration - Calling External Scripts - liquibase
有没有办法分阶段调用liquibase的外部脚本?
我正在寻找类似于 flyway 回调的东西来调用外部脚本,如 sh:https://flywaydb.org/documentation/callbacks.html
示例:
1) 预迁移:运行 sh 脚本 1
2) 运行 迁移
3) post-迁移:运行 sh 脚本 2
4) 如果迁移失败:运行 sh script 3
基本上是一种在迁移步骤中调用外部脚本的分阶段机制。
非常感谢您的反馈。
谢谢
托比
您可以 运行 外部程序(包括 sh 脚本)http://www.liquibase.org/documentation/changes/execute_command.html
如果您想 运行 在每次迁移 运行 之前和之后做一些事情,您需要这样构建您的主更新日志:
<changeSet id="preMigration" runAllways="true">
...pre migration
</changeSet>
...all your migrations are here
<changeSet id="postMigration" runAllways="true">
...post migration
</changeSet>
而且我不确定是否有错误处理程序。
谢谢 dbf
我能够使用 liquibase 运行 一个 bat 文件并将参数传递给它:
<property name="my_param_name" value="myValue"/>
<changeSet author="tobi" id="preMigration" >
<executeCommand executable="C:\projects\lbdemo\trunk\mybatfile.bat">
<arg value="Constant: ${my_param_name}"/>
</executeCommand>
</changeSet>
C:\projects\lbdemo\trunk\mybatfile.bat:
@echo off
if not exist "C:\Test\" mkdir C:\Test
set arg1=%1
(echo %arg1%) > C:\Test\EmptyFile.txt
mybatfile.bat 将创建一个 EmptyFile.txt 并将 my_param_name 值写入其中。
有没有办法分阶段调用liquibase的外部脚本?
我正在寻找类似于 flyway 回调的东西来调用外部脚本,如 sh:https://flywaydb.org/documentation/callbacks.html
示例:
1) 预迁移:运行 sh 脚本 1
2) 运行 迁移
3) post-迁移:运行 sh 脚本 2
4) 如果迁移失败:运行 sh script 3
基本上是一种在迁移步骤中调用外部脚本的分阶段机制。
非常感谢您的反馈。
谢谢
托比
您可以 运行 外部程序(包括 sh 脚本)http://www.liquibase.org/documentation/changes/execute_command.html
如果您想 运行 在每次迁移 运行 之前和之后做一些事情,您需要这样构建您的主更新日志:
<changeSet id="preMigration" runAllways="true">
...pre migration
</changeSet>
...all your migrations are here
<changeSet id="postMigration" runAllways="true">
...post migration
</changeSet>
而且我不确定是否有错误处理程序。
谢谢 dbf
我能够使用 liquibase 运行 一个 bat 文件并将参数传递给它:
<property name="my_param_name" value="myValue"/>
<changeSet author="tobi" id="preMigration" >
<executeCommand executable="C:\projects\lbdemo\trunk\mybatfile.bat">
<arg value="Constant: ${my_param_name}"/>
</executeCommand>
</changeSet>
C:\projects\lbdemo\trunk\mybatfile.bat:
@echo off
if not exist "C:\Test\" mkdir C:\Test
set arg1=%1
(echo %arg1%) > C:\Test\EmptyFile.txt
mybatfile.bat 将创建一个 EmptyFile.txt 并将 my_param_name 值写入其中。