question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add ability to drop & recreate DynamoDB table

See original GitHub issue

Is your feature request related to a problem? Please describe.

I’m just getting started with AWS Amplify. I’ve been working through the typical Todo application, when I finally got to the “GraphQL Transform” section in the docs. The first @key example is for creating a primary key, but the only way that can work with an existing Amplify project is to delete the existing DynamoDB table and update AppSync accordingly. I haven’t found a good way to do this. I’ve had to resort to using amplify api remove followed by amplify add api.

Describe the solution you’d like

It’d be helpful, I think, to have something like amplify api recreate, which would tear down the existing table and recreate it. Since this is all in-development, I’m okay losing the data. And since there’s really no way around recreating the table, I’d have to do this anyway.

I suppose an alternative would be if both tables could be created and Amplify handled the rename so the old table would be archived and the new one would be the active table.

Describe alternatives you’ve considered

I tried renaming the table manually in the AWS Console to avoid a conflict induced by the new schema. Unfortunately, that didn’t work. I think something in either AppSync or CloudFormation needs to be updated as well.

Another potential improvement is to modify the Todo API template to include a key (either primary or secondary) so the user gets sorted todo items out of the box and can be gently introduced to some of the transform DSL.

Additional context

I’d like to emphasize that this isn’t exactly a case about not thinking of my data model up front. I’m really just working through the documentation.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:36
  • Comments:27 (3 by maintainers)

github_iconTop GitHub Comments

15reactions
regenrekcommented, Apr 8, 2020

Do you have any thoughts on how the workflow would be best for you here to protect against accidental deletion?

A warning with a bold red font should do it. 😃

One thought is a “production/locked” and “dev/unlocked” mode for safety purposes, where in the dev mode the tables are automatically recreated on certain foundational schema changes.

In first place, you possibly could lock an environment like

amplify env <lock|unlock> prod

If you want to recreate tables I could think of

amplify push --recreate-tables --force amplify mock --recreate-tables or amplify mock --rebuild

Regards

9reactions
indrajitbcommented, Feb 10, 2021

Is there any solution/suggestion from either Amplify and/or DynamoDB team on the issue? I’ve run into this issue couple of times and am sure someone else will also run into the same.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Removing a table - Amazon DynamoDB - AWS Documentation
Compare removing a table using the DROP TABLE statement in a relational (SQL) database with the DeleteTable operation in Amazon DynamoDB.
Read more >
DynamoDB : Unable to recreate a table after deleting the one ...
I dropped the table using RazorSQL's DynamoDB interface. I log into the AWS console and when I query I don't see the table....
Read more >
How to Use SQL on Your DynamoDB Table With PartiQL ...
DynamoDB now supports using SQL to access your table using PartiQL. In this video, I walk you through how to use PartiQL in...
Read more >
Updating & Deleting Items | DynamoDB, explained.
Previously, we used the PutItem operation to insert Items into our DynamoDB table. We saw that this operation completely overwrites any existing Item...
Read more >
How to clear a DynamoDB table - Advanced Web Machinery
You don't need to issue a delete request to each item and pay for the write capacity it consumes. The problem with this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found