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
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