Migration generator uses new type name for old version when Union type is renamed
Nobody has claimed this yet.
- Dominant language
- Haskell
- Stars
- 95
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Description
Bug Description
When a Union type is renamed between Evergreen versions (e.g. MoralType in V51 → CompanyType in V52), the migration generator produces a function with an incorrect type signature. It uses the new type name for the old version:
migrate_LegalEntity_CompanyType : Evergreen.V51.LegalEntity.CompanyType -> Evergreen.V52.LegalEntity.CompanyType
But CompanyType doesn't exist in V51 — it was called MoralType. The correct signature should be:
migrate_LegalEntity_CompanyType : Evergreen.V51.LegalEntity.MoralType -> Evergreen.V52.LegalEntity.CompanyType
This causes the generated migration file to fail to compile.
Root Cause
In extra/Lamdera/Evergreen/MigrationGenerator.hs:
coreTypeMigration(line ~175) callsmigrateUnionDefinitionwithtypeName(the new name) instead oftypeNameOld(the old name extracted from the pattern match)migrateUnionDefinitionpasses only the new type name through tomigrateUnionDefinition_migrateUnionDefinition_(line ~279) uses the sametypeNamefor both the old and new type in the generated type signature
The Alias case (migrateAliasDefinition) already handles this correctly by accepting and using both typeNameOld and typeNameNew — the Union case was not doing the same.
Steps to Reproduce
- Have a Union type in version N (e.g.
type MoralType = SCI | SAS | SARL) - Rename it in version N+1 (e.g.
type CompanyType = SCI | SAS | SARL) - Run
lamdera checkto generate the migration file - The generated migration file will have a type error because it references the non-existent new type name in the old version's module
Fix
PR #81 threads typeNameOld through migrateUnionDefinition → migrateUnionDefinition_, following the same pattern as migrateAliasDefinition.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in extra/Lamdera/Evergreen/MigrationGenerator.hs at coreTypeMigration, migrateUnionDefinition, and migrateUnionDefinition_. Compare the Union path with migrateAliasDefinition and inspect PR #81. Done means a renamed Union generates distinct old and new type names in its signature and the resulting migration compiles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- elm, haskell
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100