如何测试飞行路线迁移? [英] How to test flyway migration?

查看:58
本文介绍了如何测试飞行路线迁移?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,迁移脚本很简单,例如添加新列等,如果部署了应用程序,则一切正常.但有时涉及一些复杂的逻辑,应该进行测试.推荐的方法是什么?

Usually migration script is simple like adding new column or so and if applications if deployed then everything is ok. but sometimes there is some complex logic involved that should be tested. what is the recommended approach?

推荐答案

有一个单独的数据库进行测试.将其作为每个构建的一部分进行迁移,并对其进行测试.您还可以通过添加第二个用于测试数据迁移的位置,根据需要填充额外的测试数据.

Have a separate DB for testing. Migrate it as part of every build and run tests against it. You can also populate it with extra test data as you desire by including a second location for test data migrations.

主要位置:

  • V1__Initial.sql
  • V2__More_changes.sql
  • V3__Complex_logic.sql

测试数据位置:

  • V2.1__Test_data.sql

然后可以在断言测试数据是否正确转换之前,在测试中调用flyway.clean()和flyway.migrate().

You can then call flyway.clean() and flyway.migrate() in a test before asserting whether the test data got transformed correctly.

这篇关于如何测试飞行路线迁移?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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