有没有办法在 Knex.js 架构中指定多列索引?还是必须一滴到raw并做一个alter table
?
最佳答案
想通了。您可以直接在表上使用 .index 可链接,并为索引字段传递一个数组并为索引传递一个名称。
knex.schema.createTable(function(table) {
table.bigInteger('_id').unsigned().primary();
table.string('fieldA');
table.string('fieldB');
table.index(['fieldA','fieldB'], 'index_name');
});
关于node.js - Knex.js 架构 : Multicolumn Index,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22362801/