# Deploy table after changing key schema

### Issue description

After changing dynamoDB table's key schema, deploying will throw an error:

> studentTable - CloudFormation cannot update a stack when a custom-named resource requires replacing. Rename studentTable and update the stack again..

### Working solution

Rename the table name in serverless.yml file from xxx to xxx2. Deploy and rename it back to xxx and deploy again and it should work.

### Tried solution

Delete the table and redeploy. Same error.

### Hint

If you set DeletionPolicy to Delete, this deployment process will delete the table with the old name. You can backup the table first and restore it later.

### Reference

[CloudFormation cannot update a stack when a custom-named resource requires replacing](https://forum.serverless.com/t/cloudformation-cannot-update-a-stack-when-a-custom-named-resource-requires-replacing/3217)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://newtons.gitbook.io/knowledge/dynamo-db/untitled.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
