generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 102
Open
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationp1pending-responseIssue is pending response from authorIssue is pending response from author
Description
Environment information
* Amplify Gen 2 data models
* Amplify CLI
* DynamoDB via CloudFormation
Describe the bug
When adding a .secondaryIndexes((index) => [ index("someField") ]) modifier to an existing model in AWS Amplify Gen 2, I observed that all existing records in the corresponding DynamoDB table were dropped. This behavior is not currently clearly explained in the “Customize secondary indexes” documentation. ([docs.amplify.aws][1])
Reproduction steps
Steps to reproduce
- Create a model without any secondary index (e.g.,
MyModel). - Seed data into the model.
- Update the model definition to include
.secondaryIndexes((index) => [ index("myField") ]). - Run
npx ampx sandbox(or equivalent). - Observe that the DynamoDB table is recreated and existing data is lost.
Expected behavior
Documentation should clearly state that adding, modifying, or removing a secondary index on a model will recreate the backend DynamoDB table, resulting in data loss unless handled via migration/export/import.
It should also provide:
- A migration strategy or warning for users with existing production data.
Actual behavior
- The doc shows how to add secondary indexes, but does not call out that doing so for a live model may delete existing data.
- Users may incorrectly assume that adding an index is a safe incremental change.
Suggested documentation improvements
- Add a section titled “Impact of modifying secondary indexes on existing data”.
- Explain that changing indexes causes the CloudFormation stack to rebuild the underlying DynamoDB table.
- Provide best practices (e.g., export data, apply schema change in a new table/environment, re-import data).
- Possibly provide example CLI/script for export/reimport.
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationp1pending-responseIssue is pending response from authorIssue is pending response from author