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

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

Open nelsongallardo opened this issue 4 years ago • 2 comments
trafficstars

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.

nelsongallardo avatar Jan 03 '21 10:01 nelsongallardo

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.

jvarho avatar Mar 22 '21 06:03 jvarho

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

marcodali avatar Nov 11 '22 19:11 marcodali