Laravel:雄辩的多列索引

时间:2018-10-17 13:39:11

标签: php sql laravel postgresql eloquent

我正在使用Laravel 5.7和PostgreSQL构建一个站点。问题是:

Schema::table('the_table', function (Blueprint $table) {
    $table->index(['column1', 'column2'], 'the_index', 'the_method')
});

等同于

CREATE INDEX the_index ON the_table USING the_method ((ARRAY[column1, column2]));

如果没有,是否有办法用Eloquent?

1 个答案:

答案 0 :(得分:0)

使用原始表达式和algorithm()

Schema::table('the_table', function (Blueprint $table) {
    $table->index([DB::raw('(ARRAY[column1, column2])')], 'the_index')->algorithm('btree');
});