Skip to content

Commit

Permalink
Merge pull request #12 from Sage/handle-preexiting-table
Browse files Browse the repository at this point in the history
Handle table creation race condition
  • Loading branch information
vaughanbrittonsage authored Feb 27, 2018
2 parents 3224a90 + 89e0fe9 commit 66db490
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/dynamodb_framework/dynamodb_table_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,11 @@ def create_table(options = {})
table[:global_secondary_indexes] = options[:global_indexes]
end

dynamodb.client.create_table(table)
begin
dynamodb.client.create_table(table)
rescue Aws::DynamoDB::Errors::ResourceInUseException => e
DynamoDbFramework.logger.warn "[#{self.class}] - Table #{table_name} already exists!"
end

# wait for table to be created
DynamoDbFramework.logger.info "[#{self.class}] - Waiting for table: [#{table_name}] to be created."
Expand Down

0 comments on commit 66db490

Please sign in to comment.