-
-
Notifications
You must be signed in to change notification settings - Fork 360
Callback to getInstance not called #546
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
Comments
Not a bug but a wrong understanding of what you're passing. This is not a callback for any command you pass by in any sense and it is not intended to be in any case. As the documentation states:
This is about the onComplete callback, which is only called on actual migration actions and for nothing else. So you can't and shouldn't expect a create command to be called, when this is a cleanup callback to close connections and do several other stuff. |
If you want to use db-migrate in a programmatic way, please use the actual programmatic options. Like https://github.com/db-migrate/api-examples/blob/master/promise.js |
@wzrdtales Then perhaps I should change this to a feature request. I have forked this in order to make run accept a callback. I don't need access to individual commands like |
@cellis Not gonna happen, run is not intended for you to run, it is the non programmatic way and it is not going to be retouched for this. And actually when you want to do something after your migration, why don't you just chain commands?
or the npm-way
There is really absolutely no need if you just want to execute something after your migrations happened to use the programmatic mode, except if you plan to interact or integrate tightly. And then for your use case this is as well just the right way instead of run. Quoting you:
|
What if i want to be able to run arbitrary commands, "scripts": {
"migrate:up": "db-migrate up && run next command",
"migrate:down": "db-migrate down && run next command",
} And that still doesn't exactly solve the problems. For instance, what happens if i want to run |
Just as documented.
|
I'm submitting a...
Current behavior
When I run the script
yarn migrate up
and there are no migrations I recieve:However, if there are migrations or I run
yarn migrate create some-migration
, this happens:Note that the callback was never called in the second example
My code is as follows:
Expected behavior
I expect a callback passed to
getInstance
to be called.Minimal reproduction of the problem with instructions
I have a file called migrate.js with the above code inside. I'm executing it like this:
$ node migrate.js
What is the motivation / use case for changing the behavior?
I would like to be able to run some additional tasks after the database is migrated.
Environment
The text was updated successfully, but these errors were encountered: