Migrate doesn't create table based on dir
Closed this issue · 4 comments
Table doesnt appear to be creating on sls offline start
, I have also tried serverless dynamodb migrate
but no table created. Is this a problem with serverless-dynamodb
not supporting the migration object? During testing I do have my amazon/dynamodb-local image running
custom:
serverless-dynamodb:
start:
docker: true
port: 8000
inMemory: true
migrate: true
seed: true
convertEmptyValues: true
noStart: true
migration:
dir: offline/migrations
Could you clarify the behaviour you expect to get with migration.dir
?
As far as I can tell, this doesn't seem to be documented or implemented in either serverless-dynamodb or serverless-dynamodb-local, but I might have missed something :)
Ah it looks like it might be based on this example, which is using an 8 year old version of serverless-dynamodb-local. The API has changed a lot since then - I'll raise a PR to fix this example so you can see how to achieve the same with the seed
key.
In the mean time, you can check out the README for examples on how to seed data: https://github.com/raisenational/serverless-dynamodb?tab=readme-ov-file#seeding-serverless-dynamodb-seed
If this isn't correct, let me know and I can reopen this issue. Thanks for bringing this to my attention :)
Ah it looks like it might be based on this example, which is using an 8 year old version of serverless-dynamodb-local. The API has changed a lot since then - I'll raise a PR to fix this example so you can see how to achieve the same with the
seed
key.In the mean time, you can check out the README for examples on how to seed data: https://github.com/raisenational/serverless-dynamodb?tab=readme-ov-file#seeding-serverless-dynamodb-seed
If this isn't correct, let me know and I can reopen this issue. Thanks for bringing this to my attention :)
Thank you for getting back to me. Yes, I am referring to the same functionality from the serverless-dynamodb-local example that you linked. The primary goal I am trying to achieve is to perform the database migration locally using just the JSON file, instead of the required resources within the serverless.yml
file. This is because I intend to use Serverless only as a local testing tool for my Lambda functions and to use Terraform for deployment.
Ah that makes sense. I think you might be able to implement that by:
- Using serverless.js or serverless.ts, and then conditionally rendering the resources block based on stage. Examples:
- Using a plugin like
serverless-plugin-ifelse