-
Notifications
You must be signed in to change notification settings - Fork 27
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
Change the Generate function to take a SchemaSource instead of a sqldb.Queryable #189
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! I fundamentally agree with what you're trying to do...but maybe think WithReverse
is a bit confusing and indicates a bigger flaw with the pg-schema-diff API.
Depending on how much work you want to do here:
With code change
Replace sqldb.Queryable
with SchemaSource
and change fromDB
to fromSchema
. This will break backwards compatibility, but I think that's okay(?)
No Code Change
- Use the
tempdbfactory
to create a database with your target schema DDL and pass that assqldb.Queryable
- Use the database schema source as the target schema
Let me know if you're interested in the more in-depth code change! I could also try to throw this together!
Thanks for having a look!
Ok, I can also go with the code change if you're OK with breaking backwards compatibility :) Any specific hints or direction for the change? I see there is already a |
The PR has been updated with the new code change :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Could you update the code example in the README.md?
Yes, it should be fixed now :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating the README.md
! Changes look good to me. Appreciate the contribution!
Thanks you for the quick review and the approval :) |
Description
This PR change the
Generate
function to take aSchemaSource
instead of asqldb.Queryable
.Motivation
We're using this library to generate migrations and this option allows us to generate forward and backward migrations, based on the wanted schema and database.
The change allows for better flexibility in
Generate
and let's us just swap arguments to the function, to generate both migrations at once.Testing
Tests with the
pg-schema-diff-test-runner
are passing locally :)