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

Application extended with method to check and install all missing migrations, not only newer ones #137

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

moroz1999
Copy link

At the moment if some migrations are not installed, application can miss them if they have an older timestamp than the last installed migration. This can easily happen when a team works on different features having different migrations alltogether, and periodically feature branches get merged into master.

@davedevelopment
Copy link
Owner

davedevelopment commented Jun 8, 2018

Doesn't the migrate command do this already?

@moroz1999
Copy link
Author

The only method in PhpmigApplication to install migrations is PhpmigApplication::up, which takes the timestamp (version) of the last installed migration and installs everything with a bigger timestamp (version).
As far as I understood, there is no way to run the "migrate" command through PhpmigApplication class, and I use it for migrations installing through http calls.

@davedevelopment
Copy link
Owner

The MigrateCommand should do this, unless I've misunderstood your problem.

Here's a screencap of it on my app:

Screenshot

@moroz1999
Copy link
Author

moroz1999 commented Aug 17, 2018

We are using PHPMig not from CLI, but by sending HTTP request to PHP script. This PHP script makes an instance of PhpmigApplication to install the missing updates. PhpmigApplication doesn't have the exact "migrate" command functionality, as in the CLI, it doesn't check the older missing migrations. This is exactly what's been added by our commit.
Please take a look at PhpmigApplication::getMigrations :
https://github.com/davedevelopment/phpmig/blob/master/src/Phpmig/Api/PhpmigApplication.php#L101
It doesn't check the missing migrations, it takes "from" and "to" parameters.
So we've added two methods to Application:
https://github.com/moroz1999/phpmig/blob/master/src/Phpmig/Api/PhpmigApplication.php#L228
https://github.com/moroz1999/phpmig/blob/master/src/Phpmig/Api/PhpmigApplication.php#L251
They don't rely only on the date, but also recheck all older migrations to get anything that's missing inbetween.
Again, there is no such problem with CLI "migrate" command.

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

Successfully merging this pull request may close these issues.

2 participants