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
support for using a custom dialect? #742
Comments
The newly added goose.NewProvider supports adding your own store implementation. WithStore This allows your custom dialect to implement the database.Store interface and use goose against that. I've been meaning to document this better. There's a bit more context here in case you're interested. |
Sounds like there's a way to do this. Will close. Thank you for such a quick response! |
I'll try to find some time to continue expanding the Reference section in the docs I've been slowly chipping away at. "Custom store" is on that list :) |
Looking at the
Looks like there's a private member to that interface. Are there any other options? |
I'll fix this up, I want to slightly expand the interface to include a Otherwise, this is ready to go. For fun, I implemented a custom https://github.com/mfridman/goose-demo/blob/main/customstore/memory/memory.go Can see the usage here: https://github.com/mfridman/goose-demo/blob/main/cmd/custom-store/main.go I also want to add Redis and then move on to some more interesting ones like duckdb. Obviously these are contrived examples, but they give an idea that goose should work with any correctly implemented Store. |
Do you plan on releasing a new version with this latest change soon? |
Yes, I typically batch a few changes and release every 1-3 months. I'll probably do the next release this weekend. |
@mfridman Hi, thank you for the option. I tried this out recently and I could not find a way to actually update the global variable store by just using I am wondering is there a way to actually set the store to be custom store, something similar as "goose.SetDialect()"? |
I appreciate how confusing this might be. The short answer is provider, err := goose.NewProvider(...)
res, err := provider.Up() When adding the new goose provider we went back and forth on whether to cut a new major version ( Please let us know if you need an example or clarification on the README or docs. Maybe in the future, we might add a global Lastly, I'm curious why you need a custom Store implementation for postgres when goose natively supports it? Footnotes
|
@mfridman I am adding a bigquery provider. And in our code, we are already using the already-implemented postgres dialect. We are trying to use goose to manage all migrations in the code for different types of databases. Used BTW, I do have a fork with bigquery dialect implemented, are you interested in adding those to official goose? If so, I can continue to work on it to match your code standard and tests. |
Yep, contributions are always welcome. I'm sure other folks would benefit from an implementation. The only tricky part is adding a supported community driver to the CLI. It's a bit of a pain nowadays because some drivers are supporting only the latest Go version, whereas with goose we try to lag 1-2 releases behind to avoid breaking folks. I'm trying to see if this is the correct path forward #664 |
I cut a v3.20.0 release this morning. I'd like to keep this issue open as a reminder to also update the documentation website. |
I started to expand the docs here: https://pressly.github.io/goose/documentation/custom-store/ I'll close this issue, but if you have any issues feel free to continue commenting or re-open. |
It would be great if there was a way to configured a custom dialect without needing to make changes to the goose codebase itself.
I'm using goose to manage postgres migrations - and I really like it, nice job 👏.
I also need to manage migrations for bigquery datasets, and I'd like to use the same tool. I could open a PR that introduces a bigquery-compatible dialect, but it would be really nice if that wasn't necessary.
The text was updated successfully, but these errors were encountered: