Consider constraints when sorting columns #20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The ordering of columns is a great option that we use for a while now. The current implementation however does not take table CONSTRAINTs into account. This results in all CONSTRAINTs to be placed in front of the columns definitions, which is not the PostgreSQL default. And it does not actually sort the CONSTRAINTs since it only sorts based on the first word of the statement.
This PR fixes both issues.
PS: most whitespace correction tools enforce files to end with a single end-of-line character by default. The dump always ends with 2. It is a small issue I also fixed here, but if you like I can place it in a separate PR.
Let me know what you think.