serverless-dynamodb-local icon indicating copy to clipboard operation
serverless-dynamodb-local copied to clipboard

Add command to drop and reset tables

Open AndrewBenzSW opened this issue 5 years ago • 6 comments

I was using this plugin against dynamodb local and resetting my data was as simple as killing serverless and restarting it. Now I'm running against DynamoDB in localstack so my data sticks around longer. So what I'd like to do is drop all the tables for a project and recreate them.

I created a plugin locally to do this locally, but I'm already using it in two places. I could just publish my plugin to npm but 90% of it is duplicated from this plugin. So I'd be happy to add a 'drop' and 'reset' command to this plugin if it's something you're interested in. I would have just created a PR with the commands, but I wasn't sure if dropping and/or resetting is something you actually don't want the plugin to do.

AndrewBenzSW avatar Oct 04 '19 19:10 AndrewBenzSW

This totally makes sense from a testing point of view. I'm in the same boat right now. @AndrewBenzSW did you actually end up adding the command?

Right now, for local dev where the plugin is not managing the db instance (i.e. a dockerized DynamoDB local with volumes for persistence) the entire local db must be manually reset by deleting individual tables then remigrating.

@AndrewBenzSW I'm assuming the behaviour you're thinking of is similar to the Rails db:reset (or any ORM really) that happens at the beginning of a test run. The idea being test data may be persisted after test runs for inspection, but not persisted across test runs.

For CI testing it's not as big of an issue as all the containers are recreated on each test run.

@aizatto or @shalithasuranga if we create a PR for this, do either one of you have time to approve it?

bryanvaz avatar Apr 14 '20 16:04 bryanvaz

I did end up creating the command but it's only used in private repos so I can't just link to what I did. I don't think it would be too hard to create a PR with the changes though.

What I built was a "drop" command which just destroyed the tables. In my package.json, I have a reset script that does a drop then migrate, which essentially does a reset. I have no problem building that in, but didn't because it was easy enough for me to just do it through npm.

Let me know if you want a PR and I can put it together.

AndrewBenzSW avatar Apr 14 '20 18:04 AndrewBenzSW

yea @AndrewBenzSW, if you have time to slap a quick PR togethe, that would be amazing.

@mjzone, saw you were the last to merge a PR before the project went quiet. Do you have a second this week to quickly review and merge the PR if @AndrewBenzSW adds the new drop/reset commands? (Or is there someone else who is managing the repo we need to ask?)

Cheers, Bryan

bryanvaz avatar Apr 14 '20 19:04 bryanvaz

Hi Brian,

As long as the drop and reset command implementation doesn't have any impact to the existing functionality, I think we can merge it.

Ashan

On Wed, Apr 15, 2020, 12:42 AM Bryan Vaz [email protected] wrote:

yea @AndrewBenzSW https://github.com/AndrewBenzSW, if you have time to slap a quick PR togethe, that would be amazing.

@mjzone https://github.com/mjzone, saw you were the last to merge a PR before the project went quiet. Do you have a second this week to quickly review and merge the PR if @AndrewBenzSW https://github.com/AndrewBenzSW adds the new drop/reset commands? (Or is there someone else who is managing the repo we need to ask?)

Cheers, Bryan

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/99xt/serverless-dynamodb-local/issues/232#issuecomment-613629963, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEZLQ7V5SWTBRGN7BENIF3RMSYRZANCNFSM4I5TZB7A .

AshanFernando avatar Apr 14 '20 22:04 AshanFernando

Awesome sauce! Thanks @AshanFernando.

@AndrewBenzSW do you have time to slap what you have into a quick PR? (I can carry it across the finish line if you give me contrib access to the PR repo)

Cheers, Bryan

bryanvaz avatar Apr 16 '20 19:04 bryanvaz

@bryanvaz Added you as a contributor. You should be able to review and merge the PR.

AshanFernando avatar Apr 20 '20 06:04 AshanFernando