From b004ddbad5c83fa20acabfa5c27904b5140c3245 Mon Sep 17 00:00:00 2001 From: Austen Collins Date: Tue, 1 Oct 2019 15:49:03 -0500 Subject: [PATCH] fix the table deletion logic and improve the error message --- serverless.js | 2 +- testProjects/serverless.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/serverless.js b/serverless.js index f5b75c9..a862c2e 100644 --- a/serverless.js +++ b/serverless.js @@ -79,7 +79,7 @@ class AwsDynamoDb extends Component { if (!equals(prevTable.name, config.name)) { // If "delete: false", don't delete the table if (config.delete === false) { - throw new Error('Your table name was changed but the old one cannot be deleted because "delete" is set to false.') + throw new Error(`You're attempting to change your table name from ${this.state.name} to ${config.name} which will result in you deleting your table, but you've specified the "delete" input to "false" which prevents your original table from being deleted.`) } await deleteTable({ dynamodb, name: prevTable.name }) config.arn = await createTable({ dynamodb, ...config }) diff --git a/testProjects/serverless.yml b/testProjects/serverless.yml index ad91116..15c3acc 100644 --- a/testProjects/serverless.yml +++ b/testProjects/serverless.yml @@ -3,4 +3,5 @@ name: test-table table: component: ../ inputs: + name: test-table delete: false