Closed mfn closed 2 years ago
I'm not sure how to do it using the fluent query builder interface, but you could modify the migration script so it calls DB::statement
after the creation statement:
Schema::create('table', function (Blueprint $table) {
// ... fluent column definitions ...
});
DB::statement("
CREATE INDEX foo_idx ON TABLE (field1, field2) WHERE (field3=false);
");
This also lets you use engine-specific language and data types in your WHERE clause.
Closing, no longer using it
I've partial indices with custom
WHERE
conditions, e.g.This gets incorrectly generated as:
Note: I'm not ware of a way to generated them using only the Builder/Fluent methods, I currently use
Schema::connection('main')->getConnection()->unprepared()
for that.Nevertheless it produces logical errors in the migrations.