-
Notifications
You must be signed in to change notification settings - Fork 1
Make it possible to run migrations as a library #2
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
base: master
Are you sure you want to change the base?
Conversation
Thanks for the PR, I feel that the main thing blocking the use of this as a library is not being able to pass through a preexisting database connection, as you pointed out. Regarding this, I think we could get away with just changing the
this would of course meaning having to create some utility function for wrangling the connection data out of the Now, when it comes to importing this package to use in an application to perform migrations, I feel that it is mostly possible to do this (assuming the aforementioned changes are made to the Granted, some of this logic could perhaps be tidied up. For example the call to Let me know your thoughts. |
I mean we could extract the DSN logic somewhere else, I think it's just going to result in a switch case somewhere else in the codebase to handle mysql/postgres/sqlite connection strings? To my mind it makes sense for each database implementation to handle mapping the config object to the DSN.
The pieces are all there, in our case it would just mean copy-pasting the contents of the half the private
We could actually even move
I think exposing a logger interface is sufficient - the lower level API is still accessible if people want full control but I think this would cover 80% of cases. |
Personally if this is going to be a library then I don't think it should really care where the database connection comes from, just that it has it. Furthermore adding a new method
Yes it makes things simple, however I think this could also be used as an opportunity to provide a more succinct API. For example, perhaps we could change the
that way we don't need to introduce a new package, and the logic would look something like,
this would break what we currently have though. Regarding logging, I personally don't think libraries should log on behalf of the user, and this is something that can be done at their own discretion when interacting with the API. |
Instead of using a separate binary with it's own config format, I'd like to be able to import this package as a library in a single deployment binary with my app.
This change makes it possible to bypass the cli library and bring your own method of configuring database connections, etc.