使用Flyway在每个环境中有条件地加载数据 [英] Using Flyway to load data conditionally per environment

查看:413
本文介绍了使用Flyway在每个环境中有条件地加载数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在每个环境中,flyway是否支持有条件地执行脚本?

Does flyway support conditional execution of a script, per environment?

例如,如果我有测试数据,是否可以创建仅在将env配置为test时才加载的测试数据脚本文件夹?

For example, if I have test data, can I create a test data script folder thats only loaded if the env is configured as test?

推荐答案

对于将来的访问者,这是针对特定于数据库的sql的解决方案,但也适用于数据加载. https://flywaydb.org/documentation/faq#db-specific-sql

For future visitors, this is a solution for DB specific sql, but applies to data loading too. https://flywaydb.org/documentation/faq#db-specific-sql

您可以设置flyway.locations = sql/common,sql/data属性,并且可以使用spring概要文件(dev/test/prod)将其设置为不同的值,而无需在生产环境中使用sql/data脚本.

You can set the flyway.locations=sql/common,sql/data property, and this can be set to different values with spring profiles(dev/test/prod), omitting the sql/data scripts on production.

这篇关于使用Flyway在每个环境中有条件地加载数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆