有没有办法在 运行 使用飞路 cli 进行实际迁移之前检查是否有待处理的迁移?

Is there a way to check if there is a pending migrate before running the actual migration with the flyway cli?

我希望能够 运行 一个命令并确定是否有待处理的迁移。这将被编写成脚本,所以最好的办法是 returns 易于解析输出的命令。

我能找到的唯一命令是 info,但输出很糟糕。我想确认是否有办法获得可解析的输出。

例如这个命令:

flyway -locations="filesystem:schema_migration_files" \
    -user="userxyz" \
    -password="lsdkfklsdfjld" \
    -url=jdbc:postgresql://myserver:5432/mydb \
    info

给我这个可怕的输出:

我可以自己解析那些乱七八糟的东西。我可能只是检查字符串“Pending”是否在输出中,但我不确定这有多可靠。我只需要确定是否存在挂起的迁移。

您可以使用-outputType=json命令行参数,然后解析输出。