回滚到FluentMigrator中的特定迁移 [英] Rollback to a specfic Migration in FluentMigrator
本文介绍了回滚到FluentMigrator中的特定迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
这里是一个批处理文件,我使用的命令行亚军工具
@echo off
如果%1 ==rollbackgoto rollback
if%1==goto migrate
if%1==versiongoto version
if%1== downgoto down
goto error
:migrate
migrate -db SqlServer2014 -connectionServer = [YOUR CONNECT STRING]-assembly[Your MigRATION ASSEMBLY]
goto done
$ b $:rollback
migrate -db SqlServer2014 -connectionServer = [YOUR CONNECT STRING]-assembly[YOUR MIGRATION ASSEMBLY]-task rollback:all
转到完成
$ b:版本
迁移-db SqlServer2014 -version%2-connection服务器= [您的连接字符串]-assembly[您的移植汇编]
goto done
:down
migrate -db SqlServer2014 -version%2 -connectionServer = [YOUR CONNEC TTION STRING]-assembly[您的移植汇编]-task rollback:toversion
:error
echo无效命令
:done
echoCompleted
然后您将使用第四个选项:down如下
$ b $ ol
所以在你的例子中,这将是下降2,这将回滚3,你会保持1和2.
更多关于< a href =https://github.com/schambers/fluentmigrator/wiki/Command-Line-Runner-Options =nofollow>命令行亚军
Suppose I have crated a three Table using FluentMigrator and gave them version Number 1, 2, 3 respectively. Now Is there any way to rollback till version 2. I mean After rollback I should have Table 1 and 2 but not 3.
解决方案
Here is a batch file I use with the command line runner tool
@echo off
if "%1" == "rollback" goto rollback
if "%1" == "" goto migrate
if "%1" == "version" goto version
if "%1" == "down" goto down
goto error
:migrate
migrate -db SqlServer2014 -connection "Server=[YOUR CONNECTTION STRING]" -assembly "[YOUR MIGRATION ASSEMBLY]"
goto done
:rollback
migrate -db SqlServer2014 -connection "Server=[YOUR CONNECTTION STRING]" -assembly "[YOUR MIGRATION ASSEMBLY]" -task rollback:all
goto done
:version
migrate -db SqlServer2014 -version "%2" -connection "Server=[YOUR CONNECTTION STRING]" -assembly "[YOUR MIGRATION ASSEMBLY]"
goto done
:down
migrate -db SqlServer2014 -version %2 -connection "Server=[YOUR CONNECTTION STRING]" -assembly "[YOUR MIGRATION ASSEMBLY]" -task rollback:toversion
:error
echo "No valid command"
:done
echo "Completed"
Then you would use the forth option: down as follows
- Open a Cmd in the directory the batch file exists, the command line runner dlls and the migration assembly dll need to exist in that directory
- Run the following [Batch File Name].bat down [Version YOU WANT TO ROLLBACK TO: i.e., Migration you want as your last one]
So in your example that would be "down 2", which will rollback 3 and you would keep 1 and 2.
More about Command Line Runner
这篇关于回滚到FluentMigrator中的特定迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文