如何在使用flywaydb时对版本控制存储过程进行版本控制?

编程入门 行业动态 更新时间:2024-10-11 11:24:15
本文介绍了如何在使用flywaydb时对版本控制存储过程进行版本控制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我目前有一个使用Microsoft SQL Server后端的Java Web应用程序。数据库迁移目前由sqlcmd手动完成,它使用:r命令引用我们的存储过程和视图的脚本文件。

I currently have a Java web app which uses a Microsoft SQL Server back end. Database migrations are currently being done manually by sqlcmd which makes use of the :r command to reference script files of our stored procedures and views.

这样每个存储过程都有他的自己的文件proc_someprocedure.sql迁移是由升级脚本6.1 upgrade.sql完成的,该脚本将proc文件引用为drop并在其当前版本中重新创建。

This way each stored procedure has his own file "proc_someprocedure.sql" The migration is done by an upgrade script "6.1 upgrade.sql" which refrences the proc file to drop and recreate it in it's current version.

我们希望迁移到flyway并让应用程序在部署时迁移它自己的数据库。但是,我找不到任何简单的方法来为每个存储过程维护单个源代码文件。如果存储过程发生更改,我需要在版本控制中对V_6_1__change.sql文件和proc_someprocedure.sql文件进行更改。

We're looking to migrate to flyway and have the application migrate it's own database upon deployment. However, I can't find any easy way to maintain a single source code file for each stored procedure. In the event that a stored procedure is changed, I need to make the change in both a V_6_1__change.sql file and the proc_someprocedure.sql file in version control.

我'我试图避免复制/粘贴的sql代码,因为它在过去困扰我们。其他人如何处理这种情况?

I'm trying to avoid copy/pasted sql code as it's haunted us in the past.. How are others handling this situation?

推荐答案

从3.0开始,没有一流的支持。但是有三种方法可以达到这个目的:

As of 3.0 there is no first class support for this. There are however 3 ways to achieve this:

  • 使用自定义MigrationResolver挂钩到你使用的任何源控件并检测那些方式的改变
  • 使用通过afterMigrate重新创建所有存储过程的FlywayCallback
  • 在单独的模式中使用单独的Flyway实例并将cleanOnValidationError设置为true。每次校验和更改时,都会清除架构并重新运行该Flyway实例管理的所有迁移

更多推荐

如何在使用flywaydb时对版本控制存储过程进行版本控制?

本文发布于:2023-11-08 06:43:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1568627.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:版本   存储过程   如何在   flywaydb

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!