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
Proposal: Automatically reorder foreign key constraint statements #405
Comments
The design sounds good to me.
Looking forward to it. Since you already seem to understand the core implementation of psqldef and I trust you, I'd like to make you a co-maintainer of sqldef if you're interested. WDYT? |
Thank you for considering me! I'd be happy to help out as a co-maintainer of sqldef. Let's do this! |
Thank you! Invited. |
FYI, pushing a git tag allows you to release a new version. I generally just release every pull request as a new version, so please feel free to do the same. |
I got it, thank you! |
Platform
--export output
Input SQL
Current output
Expected output
Currently, with sqldef, you need to consider the order of statements when adding foreign keys. Simply moving the addition of the foreign key below the creation of the
users
table would work, but having constraints related to theposts
table near theposts
table improves readability.Also, when the DDL becomes large, you may want to split the file.
In this case, you need to consider the order when merging the schema, but ideally, you want to execute it without considering the order, like this:
Proposal
To solve this problem, I propose a change in the sqldef generator to place the DDL for adding foreign keys after all create table statements.
For reference, ridgepole behaves in the same way.
Are there any design issues with this change in sqldef? If there are no problems, I will attempt to create a Pull Request.
The text was updated successfully, but these errors were encountered: