Support migrating individual alternatives in unions#90
Open
Support migrating individual alternatives in unions#90
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
(Full disclaimer: this has been AI-driven and not yet validated by a human).
Summary of Changes
I added the
ChChangeUnionAltchange type to enable writing:Modified Files:
src/Data/API/Changes/Types.hs:ChChangeUnionAlt TypeName FieldName APIType MigrationTagconstructor toAPIChangeppLinescase for pretty-printing the new change syntaxsrc/Data/API/Parse.y:UnChChange FieldName APIType MigrationTagvariant toUnionChangealternative changedunionChangeToAPIChangeconversion casesrc/Data/API/Changes.hs:applyAPIChangeToAPIcase for schema validationapplyChangeToDatacase for Aeson JSON value migrationapplyChangeToData'case for the generic Value representationchangeTagscase to include the migration tag in the set of field migrationsvalidateAftercase for proper validation behaviorTest suite (
tests/Data/API/Test/UnionMigration.hsandUnionMigrationData.hs):TestRecordwithin a union by adding anamefield with value `"id_"How It Works:
When migrating a union alternative:
fieldMigrationmechanism as record field changesThe migration tag
MigrateBarOldToBarNewwould be defined in theFieldMigrationenumeration type generated bygenerateMigrationKinds, and the actual migration logic provided via thefieldMigrationfield of theCustomMigrationsrecord.