Improve support for various postgres types in generated migrations #4749
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.
This commit improves the handling of various postgres types during the generation of migrations.
For array types we did emit the array brackets in the wrong place. That's fixed now.
We did not handle
Range
norMultirange
before. This is now handled to generate the correct range type instead.We also did not handle
Record<…>
in any way. As postgres does not support anonymus record types we instead generate a named type that matches that record definition. We take care that the up and down migration create and drop the relevant type and that this also handles nested variants. We also take care to not generate type names with more than 64 bytes, as postgres truncates anything that has a longer type name. For now diesel-cli returns an error if such a type name would be generated.I added two test cases to cover these variants.
Closes #4706
Closes #4705