-
Notifications
You must be signed in to change notification settings - Fork 116
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
Fix migrations being run when nothing changes #551
Conversation
…not lead to migrations being re-run
Can you add a test case for this? |
The In my original implementation, the migrator had a protected If you are O.K. with adding this property and a getter as described, I would then be able to test this, and also the two cases where a connection should be dropped. Or do you see an alternative way to test the feature? |
There is actually a way to test the feature without changing the src code. Simply by performing an insertion before running the migrator, and seeing if the connection gets truncated or not. On my way implementing that... |
Could a test for this be to add a new source directory. Then partially run those migrations, and then use migrator and check its log output? That isn't the best test but it covers the user facing behavior at least. |
The path I am taking right now is to run the migrator, set the end date of the entry in the phinx log to 'Foo', and re-run the migrator. If the end_date is 'Foo', the migrations were not re-run. if the end_date is now, the migrations were re-run.
|
The problem I am facing now, is that if we run: $migrator->runMany([
['plugin' => 'Migrator',],
['plugin' => 'Migrator', 'source' => 'Migrations2',],
], false); the first set of migrations sees the migrations of the second set as missing. So the migrations get re-run again. |
I think in this configuration, with several sets of migrations targeting the same migration table, there is no way to avoid that migrations get re-run every time. But this is really a hedge case. This will not re-run the migrations: $migrator->runMany([
['plugin' => 'Migrator',],
['source' => '../../Plugin/Migrator/config/Migrations2',],
], false); |
Running an integration test for this seems reasonable. We don't always need to test the single function that should affect it. |
Just to make sure we are on the same page here: |
Co-authored-by: Mark Story <[email protected]>
Thank you 🎉 |
Fixes #533