From 3e335d4cef904ac25a8296c7544630977ee0ceb7 Mon Sep 17 00:00:00 2001 From: Elad Ben-Israel Date: Wed, 3 Apr 2024 02:53:52 +0300 Subject: [PATCH] fix(dynamodb): cannot reuse container since table already exists (#176) Now since the container might be reused across simulator updates, we need to make sure we clean up the table before it's being created. I've tested this manually because I am not sure how to test this. --- dynamodb/dynamodb.sim.w | 4 ++++ dynamodb/package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dynamodb/dynamodb.sim.w b/dynamodb/dynamodb.sim.w index ab2628ff..745623f6 100644 --- a/dynamodb/dynamodb.sim.w +++ b/dynamodb/dynamodb.sim.w @@ -139,6 +139,10 @@ pub class Table_sim impl dynamodb_types.ITable { return nil; })(); + // delete the table if it already exists because we might be reusing the container + try { client.deleteTable({ TableName: tableName }); } + catch e { } + util.waitUntil(() => { try { client.createTable({ diff --git a/dynamodb/package.json b/dynamodb/package.json index 8f8a931e..b0593a31 100644 --- a/dynamodb/package.json +++ b/dynamodb/package.json @@ -1,6 +1,6 @@ { "name": "@winglibs/dynamodb", - "version": "0.1.0", + "version": "0.1.1", "description": "DynamoDB library for Wing", "author": { "name": "Cristian Pallarés",