Skip to content

Conversation

weiznich
Copy link
Member

@weiznich weiznich commented Sep 5, 2025

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 nor Multirange 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

4A6F6F6E61 and others added 3 commits September 3, 2025 17:19
This commit adds some tests for the fixed array migration generate case.
It also adds test cases and fixes for:

* Ranges
* Multiranges
* Records, here we generate a new composite type for each record field
  used in the table definition as postgres doesn't support anonymus
  composite types. There is also a limitation in how deep you can nest
  these types until you run into the 64 byte type name limit for 
  postgres.
* Nested variants of all of that above.
@weiznich weiznich requested a review from a team September 5, 2025 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Weird Array Behaviour
2 participants