this.table = new dynamodb.Table(this, `${stackName}-${id}`, {
tableName: `${stackName}-${id}`,
partitionKey: { name: 'message_id', type: dynamodb.AttributeType.STRING },
sortKey: { name: 'entityId', type: dynamodb.AttributeType.STRING },
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
tableClass: dynamodb.TableClass.STANDARD,
stream: dynamodb.StreamViewType.NEW_IMAGE,
timeToLiveAttribute: 'ttl',
removalPolicy: RemovalPolicy.DESTROY,
});
But I need to change that partitionKey
from message_id
to messageId
. Is there any way to do this programmatically? Or do I have to manually delete the table in every environment? This hasn't been deployed to production yet but it has been deployed to dev env.
You will have to delete and recreate the table to change the name of the partition key and/or sort key.
Heck, you can't even change the value of the PK of a record in DDB.