99x / serverless-dynamodb-local

Serverless Dynamodb Local Plugin - Allows to run dynamodb locally for serverless
MIT License
625 stars 233 forks source link

Every time I restart dynamodb local and run "sls dynamodb start" the content of the DB is wiped #259

Open nelsongallardo opened 3 years ago

nelsongallardo commented 3 years ago

Actual Behaviour

i run sls dynamodb start - I populate the database, I stop dynamodb local and run it again, and table is recreated and content wiped.

This is my .yml configuration

dynamodb:
    start:
      migrate: true
      inMemory: false
   stages:
      - ${self:provider.stage}

Expected Behaviour

Given that inMemory: is set to false I would expect the data to be written to disk and next time I restart the server the data should be there.

Steps to reproduce it

Just start server with sls dynamodb start - populate some data, and restart the server and data will be gone.

jvarho commented 3 years ago

Using migrate: true means recreating tables on start. If you drop that your data should persist, but you will need to manually migrate if you make changes.

marcodali commented 1 year ago

what are the steps to persist the data between restarts?

EDIT: If you want your tables to start with dummy data instead of empty, follow the next steps:

  1. use seed: true next to inMemory: true inside dynamodb section in serverless.yml
  2. In serverless.yml create a new section inside custom > dynamodb > seed like this
  3. You need a json file with dummy data to fill your table with the properties matching the same data type defined for your table

That's it, the next time you run sls offline start your tables will automatically be filled with the dummy data from your json files