Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Executing "older" migrations #16

Open
luca-rath opened this issue Nov 2, 2022 · 5 comments
Open

Executing "older" migrations #16

luca-rath opened this issue Nov 2, 2022 · 5 comments

Comments

@luca-rath
Copy link

If there exists a migration, that has not been executed yet, with a timestamp older than the last executed migration in the project, that migration will show with status n/a when executing bin/console phpcr:migrations:status, but running bin/console phpcr:migrations:migrate will never execute that migration. You would have to downgrade all newer migrations, then upgrade that specific migration and finally upgrade all newer migrations again. This usually happens, when you upgrade a bundle which has new migrations.

image

Doctrine-Migrations handles this by just executing all the non-executed migrations in the order of their timestamp, no matter if there are newer migrations that have already been executed.

@luca-rath
Copy link
Author

Not sure if this issue belongs here or in the PHPCR Migrations Bundle

@dbu
Copy link
Member

dbu commented Nov 2, 2022

afaik the logic for migrations is here and not in the bundle, so the issue seems in the right place.

@dantleech built the migrations tool, lets see if he has some input on this?

@dantleech
Copy link
Member

dantleech commented Nov 2, 2022

I guess it would be fine to copy the behavior of the Doctrine bundle here, but also sounds like a potential issue.

If that migration were executed it could invalidate all subsequent migrations? Could the solution rather be to delete it and create a new migration?

@luca-rath
Copy link
Author

Deleting such a migration is not possible, if it lives inside a bundle you don't have control over. As a quick fix, you can of course just ignore that migration and duplicate it in your project and just adjust the timestamp, because the original migration won't be executed anyways.

Another solution would be, to just add the possibility for executing a single migration (like the bin/console doctrine:migrations:execute command). In this case, such a migration would still never be executed automatically, if there are newer migrations already executed, so you're in full control.

@dbu
Copy link
Member

dbu commented Nov 7, 2022

i do like the idea of a command to execute a single migration, that seems a useful functionality.

i think i would also attempt to run all missing migrations like doctrine does. with doctrine, there is the same potential problem with deletions, if migrations are not seen strictly in order, but i would expect migrations to usually add things. or remove something that will not later be added to again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants