【发布时间】:2020-10-12 06:24:36
【问题描述】:
使用 AWS Amplify,我终于删除了我的一个模型的 @key 属性(我不需要它,我想要一个自动生成的 UUID)。
执行amplify push 时出现此错误
Attempting to edit the key schema of the NewsTable table in the News stack.
An error occured during the push operation: Attempting to edit the key schema of the NewsTable table in the News stack.
我该如何强制? 我不介意丢失数据,因为它不在生产中。我只是不想用糟糕的重命名来破解它,也不想为此删除我的整个 App Sync 项目。
【问题讨论】:
-
我发现的快速破解:我添加了一个虚拟@model,并从 schema.graphql 中完全删除了我的 News 模型。我推了它,它起作用了。然后我放回我的新闻模型并移除我的虚拟模型(没有钥匙)。它奏效了。但这是真正的方法吗?
-
我采用了完全相同的方法。我不同意。我观察到,当先前环境中的数据绝对是一次性的时,我始终可以使用 amplify cli 创建具有修改模式的单个新环境,并删除现有的先前环境。
amplify push限制来自 DynamoDB,因为 GSI 是在创建 DynamoDB 表时创建的。与表迁移相比,新环境的工作量肯定更少。 -
虚拟模型是什么意思?只是为了推动它?如果是这样,为什么需要它来删除密钥?举个例子就好了。
-
我会添加一个更详细的答案@PeteDuncanson
标签: amazon-web-services aws-amplify aws-appsync