This repository was archived by the owner on Jun 19, 2023. It is now read-only.
error on ensureTableExists and also in create table. #124
Open
Description
As seeing in the dynamodborm I write a schema in another file, with the notation of data-marshaller. And now I building a migration tool, so using the features tha handle life cicle of the table.
So it cames the surprises
if I write the schema this way
{
id: {
type: 'String',
keyType: 'RANGE',
defaultProvider: v4,
},
customerId: {
type: 'String',
keyType: 'HASH',
},
paymentMethodId: {
type: 'String',
},
}
it throws this:
ERROR::: { ValidationException: Invalid KeySchema: The first KeySchemaElement is not a HASH key type
at Request.extractError (/home/lgsantana1/Repos/domain-payment-account/node_modules/aws-sdk/lib/protocol/json.js:48:27)
at Request.callListeners (/home/lgsantana1/Repos/domain-payment-account/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/home/lgsantana1/Repos/domain-payment-account/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/home/lgsantana1/Repos/domain-payment-account/node_modules/aws-sdk/lib/request.js:683:14)
at Request.transition (/home/lgsantana1/Repos/domain-payment-account/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/home/lgsantana1/Repos/domain-payment-account/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /home/lgsantana1/Repos/domain-payment-account/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/home/lgsantana1/Repos/domain-payment-account/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/home/lgsantana1/Repos/domain-payment-account/node_modules/aws-sdk/lib/request.js:685:12)
at Request.callListeners (/home/lgsantana1/Repos/domain-payment-account/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
message: 'Invalid KeySchema: The first KeySchemaElement is not a HASH key type',
code: 'ValidationException',
time: 2018-11-14T21:25:33.572Z,
requestId: 'BTA4O2LQ72GKM0GQ57KEPLAHINVV4KQNSO5AEMVJF66Q9ASUAAJG',
statusCode: 400,
retryable: false,
retryDelay: 26.053755885556207 }
this way everthing works properly:
{
customerId: {
type: 'String',
keyType: 'HASH',
},
id: {
type: 'String',
keyType: 'RANGE',
defaultProvider: v4,
},
paymentMethodId: {
type: 'String',
},
}
Just the order of props inside the schema object.
So you can say day everthing is fine, just change the order... Well, this condition is also present in the indexes. And I have this case:
customerId: {
type: 'String',
keyType: 'HASH',
},
id: {
type: 'String',
keyType: 'RANGE',
indexKeyConfigurations: {
'id-index': 'HASH',
'paymentMethodId-id-index': 'RANGE'
},
defaultProvider: v4,
},
paymentMethodId: {
type: 'String',
indexKeyConfigurations: {
'paymentMethodId-id-index': 'HASH'
},
},
if I remove the 'paymentMethodId-id-index' everthing works properly. But because the mapper firs see the RANGE it throws.
GENERAL NOTE: I omited in here the validator
propertie of dynamodborm for clarity.