I'm new. I used amplify studio to create a scheme in the "Data" tab. It was pretty good, but I needed to add a few things. So I edited the files locally. When I do amplify push it causes me to lose all my changes. I can use get to revert back to before the amplify push but I cant figure out how to save my local changes to the cloud.
#✅ - `amplify push` causes loss of local changes
1 messages · Page 1 of 1 (latest)
hey @viscid lark , did you run amplify pull before making changes to the resources locally?
for example: when making changes on Amplify Studio, you will need to run amplify pull to sync the changes. The local may have may have overridden the changes in Amplify studio. additionally, could you provide us a screenshot/video of the behaviour you are experiencing?
I might not have done amplify pull before making changes...so here's what I just tried... At this point, I have no uncommited changes in git. I made a change in amplify studio to the a data type in the Data section. I deployed that, and then did amplify pull --appId mythinghere --envName staging. After doing git status I can see that it changed two schema files, and two unrelated components I had built in "UI Library" but had manually modified (and committed to git). so I did get checkout on the two files that werent supposed to change, and then git commit/push'd the two schema files. Then I did amplify push. And, it reverted those same two files again. I cant move on until I figure this out. Its not clear how to get my changes from local to amplify although it is clear that this has happened a number of times previous. Its just not happening now.
hey @viscid lark , just to confirm the local loss of changes are the UI components or the Data model?
UI components... so for example, I add default values to form inputs, or logic that occurs on submit.
Then, I make a change to the data model through the amplify studio webpage. I do amplify pull and the UI components are lost and I have to check them out of git to get them back.
They are also lost when I do amplify push
@viscid lark thank you for the clarification. This is currently the expected behaviour, when the making changes to the data model and running a push or pull the ui-components folder will get regenerated.
we could skip the ui generation using --no-codegen flag found here: https://github.com/aws-amplify/amplify-cli/blob/dev/packages/amplify-util-uibuilder/src/commands/utils/shouldRenderComponents.ts#L17
but to generate the API models in the src folder you will have to run amplify codegen models .
Ahh, I see. Thank you for the help. So when I make a change to the data model only, I pass --no-codegen and then manually generate models with amplify codegen models and when I make changes to UI only (in UI builder) then I allow codegen, then recover all my manual changes that are lost and manually merge them in. Does that sound right?
yes, thats correct. you can just run amplify pull to regenerate the components folder. I would also suggest utilizing the override functionality for the components to make changes on the client side.
please refer to: https://docs.amplify.aws/console/uibuilder/override/#extend-generated-components-via-overrides-prop
✅ - amplify push causes loss of local changes