amazon-web-services - serverless-dynamodb-local 没有迁移新的全局二级索引
问题描述
我正在使用serverless-offline
和开发 AppSync + DynamoDB serverless-dynamodb-local
。我添加了新的全局二级索引并使用以下命令进行迁移。
$ serverless dynamodb migrate
接下来,我开始使用以下命令进行本地调试。
$ sls offline start
我查询但失败了。
{
"version" : "2017-02-28",
"operation" : "Query",
"index" : "groupId-index",
"query" : {
"expression": "groupId = :groupId",
"expressionValues" : {
":groupId" : $util.dynamodb.toDynamoDBJson($ctx.args.groupId)
}
}
}
Error while executing Local DynamoDB
{
"version": "2017-02-28",
"operation": "Query",
"index": "groupId-index",
"query": {
"expression": "groupId = :groupId",
"expressionValues": {
":groupId": {
"S": "group-001"
}
}
}
}
ValidationException: The table does not have the specified index: groupId-index
我的 dynamodb 表定义serverless.yml
是
UserTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: UserTable
KeySchema:
-
AttributeName: id
KeyType: HASH
AttributeDefinitions:
-
AttributeName: id
AttributeType: S
-
AttributeName: groupId
AttributeType: S
BillingMode: PAY_PER_REQUEST
GlobalSecondaryIndexes:
-
IndexName: groupId-index
KeySchema:
- AttributeName: groupId
KeyType: HASH
Projection:
ProjectionType: ALL
我的 serverless-dynamodb-local 配置是
dynamodb:
stages:
- dev
start:
port: 8000
inMemory: true
migrate: true
seed: true
seed:
dev:
sources:
- table: UserTable
sources: [./migrations/user.json]
- table: ChatMessageTable
sources: [./migrations/chatMessage.json]
我应该怎么办?我在没有本地测试和从 appsync 控制台查询的情况下部署并成功。所以我认为配置文件是有效的。
编辑1:这是我的serverless start offline
日志。
Dynamodb Local Started, Visit: http://localhost:8000/shell
Serverless: DynamoDB - Warn - table UserTable already exists
Serverless: DynamoDB - Warn - table ChatMessageTable already exists
Seed running complete for table: UserTable
Seed running complete for table: ChatMessageTable
我删除.dynamodb
文件夹和serverless dynamodb install
. 但是出现了同样的消息。
解决方案
推荐阅读
- google-apps-script - 如何隐藏 3 天前的列
- c# - Excel 无法正确排序来自 C# 导出的日期列
- sql - 查找具有相同值和特定不同值的记录的最快查询
- angular - 模板文件中的“AbstractControl”类型不存在属性“控件”
- algorithm - 这个特定结构的嵌套循环的时间复杂度应该是多少?
- java - 如何判断包属于哪个模块?
- javascript - SQL更新不更新任何东西
- typescript - 如何在玩笑中忽略打字稿错误
- jsf - 非选定项目的 JSF 验证
- multithreading - 如何在 OptaPlanner 中创建多线程自定义移动工厂?