Open heskyji opened 7 years ago
OOI, could you not just use rollback?
@rquadling Yes I could. That would be my workaround for now.
Since migrate
command does not only support migrating forward, but also supports migrating to a Migration ID in the past; then users would expect it behaves the same as rollback
when it tries to migrate backwards, which need to respects the version_order:execution
setting and any breakpoints.
In my case, it is important to have one consistent way to migrate to any point (i.e. a given Migration ID) that is associated to a release artifact. That point might be the latest migration, and might be anywhere in the execution history.
Hope that makes sense. Thanks.
I can certainly see the issue you are having.
My concern is how to deal with migrating to a point in the past that still has unmigrated migrations.
If the migration target is in the past, it may well be easiest internally if we first call 'rollback' and then 'migrate' command to the same target.
For the time being, maybe a simple shell script that does both of these commands.
It is still migrating forward when migrating to a point in the past that still has unmigrated migrations. So I guess phinx would apply the oldest unmigrated migration first. That shouldn't be a problem.
Is this still an issue?
@dereuromark I actually haven't been using it since August. So I couldn't validate it at this point. Unless an improvement has been merged in, I assume it is still an issue.
Currently
migrate
command does not respectversion_order:execution
config or breakpoints likerollback
command does.I have a CD environment for our main codebase. I'm using phinx in a separate codebase to manage its database. I'm using the
version_order:execution
config. For each CI build that triggered by a code merge, I store theMigration ID
in the artifact. Then during deployment, I want to runmigrate -t {Migration ID}
together with the main artifact deployment. Please note this need to support rolling back the entire system to an old artifact.Right now, when if I run
migrate -t {Migration ID}
, where{Migration ID}
is in the past when I do a system roll back, phinx will rollback all the migrations that are created after that{Migration ID}
and disregard any existing breakpoint. I think this is wrong, it should detect the{Migration ID}
is in the past then perform same behaviour asrollback -t {Migration ID}
, which respect theversion_order:execution
config and any breakpoint.For the CD environment I described above, this is very important because I can then have a consistent method to handle database migrations for my deployments, doesn't matter if it is a new release or a rollback.
My workaround right now is that in the deployment process, I have to check if the
{Migration ID}
isup
ordown
. If it isdown
, I callphinx migrate -t {Migration ID}
; if it isup
, I will have to callphinx rollback -t {Migration ID}
.Thanks.