-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't edit/remove @primaryKey field w/ amplify push --allow-destructive-graphql-schema-updates when @hasMany field declared #99
Comments
Hi
|
@sachscode I'm having a similar issue. For me, I have a model that has a @manytomany connection that has been pushed. Then, I update that models primary key to a new field and I get the error. Have you tried that sequence of events? |
I have been having the same issue for the last couple of days, though I haven't confirmed if it is in fact caused by the presence of the @hasmany directive in my model. I will try to manually remove the @hasmany relationship first and will report back with the results. This is issue is causing a huge slow down during active development while evolving my schema. Is there a way to just tell amplify during the push operation to forget about all existing resources and rebuild the api or the entire environment from scratch? It seems that --allow-destructive-graphql-schema-updates is a less destructive method, but if I don't really care about any data in my test environment having a nuclear option would be a good enough workaround for now. |
I got rid of all the @hasmany relationships in my model and I was still unable to change @PrimaryKey. Got the same error message about the failed deployment. I also got rid of all @Index directives and still no joy. At this point the only thin that worked was commenting out the model and all relationships to it from other tables, then doing a push, followed by re-adding the model with the new @PrimaryKey, then doing another push. Maybe it had something to do with my @auth directive being dependent on the field that I wanted to use for the new @PrimaryKey? But I don't have time to test every possiblity today. |
Thank you @brentcappello for the six step workaround you provided in your question, it saved my life today. I was absolutely furious at Amplify, but the steps you described worked flawlessly. Thank you!! |
Ran into this issue with no @hasmany relationships. Running into this when trying to mark a field that isn't "id" as the primary key. My suspicion is if the table isn't initially created with a field other than id being used it will fail when you try to mark any other ones with @PrimaryKey in subsequent updates. |
Before opening, please confirm:
How did you install the Amplify CLI?
npm
If applicable, what version of Node.js are you using?
16.13.0
Amplify CLI Version
7.6.22
What operating system are you using?
Mac
Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
No manual changes
Amplify Categories
api
Amplify Commands
push
Describe the bug
I received an error while trying to
amplify push --allow-destructive-graphql-schema-updates
I could not modify or remove the field
@primaryKey
while I had another field using@hasMany
In the example below I couldn't remove the
@primaryKey
on the username field without getting the error.I was able to workaround the error and get a proper deployment with this sequence:
@hasMany
amplify push
@primaryKey
from fieldamplify push --allow-destructive-graphql-schema-updates
@hasMany
amplify push
Expected behavior
Expected to see
amplify push --allow-destructive-graphql-schema-updates
command succeed.Or perhaps a more detailed error message stating I cannot modify/remove an existing PK while using a relationship.
Reproduction steps
@primaryKey
amplify push --allow-destructive-graphql-schema-updates
Make sure you have a field with
@hasMany
declared and a reciprocating Model and field with@belongsTo
GraphQL schema(s)
Log output
Additional information
I was able to workaround the error and get a proper deployment with this sequence:
@hasMany
amplify push
@primaryKey
from fieldamplify push --allow-destructive-graphql-schema-updates
@hasMany
amplify push
The text was updated successfully, but these errors were encountered: