Skip to content

Commit 6278d6d

Browse files
committed
fix(index): make use of tableName when dropping index
Signed-off-by: Tobias Gurtzick <magic@wizardtales.com>
1 parent abbe312 commit 6278d6d

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,26 @@ var CockroachDriver = Base.extend({
313313
callbacks: callbacks,
314314
constraints: constraint.join(" ")
315315
};
316+
},
317+
318+
removeIndex: function(tableName, indexName, callback) {
319+
var sql;
320+
if (arguments.length === 2 && typeof indexName === "function") {
321+
callback = indexName;
322+
indexName = tableName;
323+
tableName = null;
324+
} else if (arguments.length === 1 && typeof tableName === "string") {
325+
indexName = tableName;
326+
tableName = null;
327+
}
328+
329+
if (tableName) {
330+
sql = util.format('DROP INDEX "%s"@"%s"', indexName, tableName);
331+
} else {
332+
sql = util.format('DROP INDEX "%s"', indexName);
333+
}
334+
335+
return this.runSql(sql).nodeify(callback);
316336
}
317337
});
318338

0 commit comments

Comments
 (0)