aws-amplify / aws-amplify/amplify-cli

[gen2-migration] DynamoDB table mappings are derived from the stale compiled build/schema.graphql with no active-schema cross-check

Open
#14,978 0 comments 0 reactions 0 assignees View on GitHub
gen2-migration
Dominant language
TypeScript
Stars
2.9k
Forks
825
Avg merge
11d 23h
Merged PRs (30d)
2

Description

## Summary
`generate` derives `migratedAmplifyGen1DynamoDbTableMappings` from the compiled build artifact `api//build/schema.graphql` (by matching `ModelXConnection` types), without cross-checking against the active, user-edited schema. A model whose `@model` was commented out or removed after the last compile still appears in the stale build schema, so a mapping is emitted for a model that does not exist in the generated Gen2 schema. Enabling adoption then fails downstream during import extraction.

## Downstream symptom
`Imported model not found in schema: `

## Details
- `packages/amplify-cli/src/commands/gen2-migration/generate/amplify/data/data.generator.ts` (~L259-269) builds the mapping from `build/schema.graphql`; the active schema is read separately in `collectUserSchema()` (~L229-239) and the two are never reconciled.

## Expected
Cross-check mapping generation against the active schema (omit mappings for models not present in the active schema), or guard import extraction to skip models absent from the active schema.

## Type
Bug

Contributor guide

Open the contributing guide

Research direction

Start in packages/amplify-cli/src/commands/gen2-migration/generate/amplify/data/data.generator.ts, reading collectUserSchema() around L229-239 and the mapping logic around L259-269. Run the gen2-migration generate flow with a model removed or commented out after compilation, then verify mappings omit models absent from the active schema and import extraction no longer reports “Imported model not found in schema.”

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
backend-api-design, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.