Repository navigation
feat: Allow changing a table id type between int and uuid - #3299
Conversation
SandPod
left a comment
There was a problem hiding this comment.
Nice work!
Had a couple of nits and suggestions in different places. But my main concern is around iterators in tests. Wrote some motivation around why these are generally not a great idea. But I'm up for exploring if we can alievate my pain points while still maintaining the simple way to add features.
It would be great to explore what the minimal set of tests that are required are as well. Then we could probably reduce what is run in these iterators and hopefully just type them out.
|
Still pending to follow-up in the tests revision, but will get to them very soon! |
SandPod
left a comment
There was a problem hiding this comment.
Specifically looked at the changes regarding the comments that have been addressed.
…for changed id type
SandPod
left a comment
There was a problem hiding this comment.
This is looking good to me!
Had a last couple of questions then we are ready to go I think :)
SandPod
left a comment
There was a problem hiding this comment.
Big change and really nice improvement to the framework!
Thank you for all the great work here! 🙏
This PR implements the first feature described at #3255: allow the user to declare the id field type in serverpod models, changing its type to one of the supported id types (with the correct default attribution).
The implementation changes the following:
changeIdType. The user is only allowed to declare the id field and change its type if this experimental feature is enabled.defaultkey can be specified. For theinttype, thedefaultkey is optional with the valueserial; for all others, it is required.SupportedIdTypeclass. Currently supportsint(default) anduuid(withdefault=randomto generate UUIDv4 values).The missing test for the PR #3257 is implemented in this PR. It validates that the stored FK field type on the relation objects is being collected from the correct model. Its the file
relation_changed_field_id_type_test.dartof theserverpod_climodel validation tests.Most of the id type tests were implemented with a little abstraction to ensure that all supported id types (current and future) are working as expected - both in isolation and in relations. This way, new supported id types in the future will be already 99% covered by tests, pending only to add one single line in the
migration_sql_test.dartfile to complete the coverage.Closes: #3255
Pre-launch Checklist
///), and made sure that the documentation follows the same style as other Serverpod documentation. I checked spelling and grammar.If you need help, consider asking for advice on the discussion board.
Breaking changes
No breaking changes.