Skip to content

Commit

Permalink
waitUntilTableActivate and all indexes are active
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Krail authored Oct 2, 2017
1 parent 28c8e85 commit 6ac5936
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/migrate/migrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,17 @@ Migrator.prototype.waitUntilTableActivate = function(tableName){
var timer = setInterval(function(){
self.npd().table(tableName).describe().then(function(result){
if(result.Table.TableStatus === 'ACTIVE'){
clearInterval(timer);
timer = null;
resolve(result);
var success = true;
result.Table.GlobalSecondaryIndexes.forEach(function(index){
if(index.IndexStatus !== 'ACTIVE'){
success = false;
}
});
if(success){
clearInterval(timer);
timer = null;
resolve(result);
}
}
}).catch(function(){
console.log('Resource in used.');
Expand Down

0 comments on commit 6ac5936

Please sign in to comment.