Currently, I can do db.addIndex to add a new index to a table.
However, there is no support for partial indexes.
Partial index example in raw sql for postgresql:
'create unique index account_id_name_index on foo(account_id, name) where bar_id IS NULL'
Currently the addIndex method signature looks like this:
addIndex: function(tableName, indexName, columns, unique, callback) {
if (typeof(unique) === 'function') {
callback = unique;
unique = false;
}
if (!Array.isArray(columns)) {
columns = [columns];
}
var sql = util.format('CREATE %s INDEX "%s" ON "%s" (%s)', (unique ? 'UNIQUE' : ''),
indexName, tableName, this.quoteDDLArr(columns).join(', '));
return this.runSql(sql).nodeify(callback);
},
We could either modify the existing method signature by accepting another parameter that specifies the where clause, or a new method addPartialIndex.
Do you think that this is something you'd like added in? If yes, I wouldn't mind working on adding this feature in as I am currently using db-migrate for work and currently we resort to using raw sql to create the partial indexes, but it would be a nice to have if the db-migrate SQL API allowed for this.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Currently, I can do db.addIndex to add a new index to a table.
However, there is no support for partial indexes.
Partial index example in raw sql for postgresql:
'create unique index account_id_name_index on foo(account_id, name) where bar_id IS NULL'Currently the
addIndexmethod signature looks like this:We could either modify the existing method signature by accepting another parameter that specifies the where clause, or a new method
addPartialIndex.Do you think that this is something you'd like added in? If yes, I wouldn't mind working on adding this feature in as I am currently using db-migrate for work and currently we resort to using raw sql to create the partial indexes, but it would be a nice to have if the db-migrate SQL API allowed for this.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.