-
Notifications
You must be signed in to change notification settings - Fork 93
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
Callback during migration #67
Comments
Doesn't it print out that it's starting a migration, and then again when it's finished? Or do you mean some sort of ticker to show something is still happening as far as we know? |
Yes, it does print output, but that's not at all flexible. Think progress bar. If we have a callback that is executed after each individual migration then we can completely customize the display to the user. Displaying progress bars, spinning icons, or whatever we want via CLI or GUI: $api = new Phpmig\Api($container, $output);
$total = count($api->getMigrations($api->getVersion()));
$count = 0;
$callback = function($version) use (&$count, $total) {
// Elaborate progress bar handler code here
$count++;
}
$api->up($this->getVersion(), $callback); Edit $callback = function($version, $total, $count) {
// Elaborate progress bar handler code here
} |
I see what you mean. My preference would be for the observer, pub sub or mediator pattern. |
Right, observer would be much more flexible. How do you foresee attaching the observer? I think it's necessary to attach it to Phpmig\Api, given that it's really the only piece that is aware of the total number of migrations to process (although #66 is set to change that). Maybe #66 blocks this? Some ideas: $api = new Phpmig\Api($container, $output);
$progress_observer = new ObjectThatImplementsSplObserver();
$api->attachObserver($progress_observer);
$api->up($this->getVersion()); Or attach via container? I personally don't like the idea of passing a global container into a constructor, but that's a different discussion altogether. $container['phpmig.observers'] = new \ArrayObject(new ObjectThatImplementsSplObserver());
$api = new Phpmig\Api($container, $output);
$api->up($this->getVersion()); |
I'm thinking of adding callback support to the migration process. This would be especially useful in the API migration.
Why?
There's no feedback during migration processing. This can leave users feeling as if the app has stalled when processing a significant number of migrations.
A callback that is executed after each migration is processed would allow feedback to be presented to the user on the progress.
Thoughts?
The text was updated successfully, but these errors were encountered: