Skip to content

Add support unique indexes with where to Blueprint

Compare
Choose a tag to compare
@pvsaintpe pvsaintpe released this 09 Jul 14:07
· 72 commits to master since this release
Feature/unique wheres (#5)

Extending creating unique indexes with conditions on where, example:

```
Schema::create('cities', static function (Blueprint $table) {
       ... 
       $table->uniquePartial(['name', 'author_id'])
            ->where('editor_id', 1)
            ->whereRaw('field1 = ? and field2 <= ?', ['field1', 'field2'])
            ->whereNotNull('deleted_at')
            ->whereBetween('author_id', [1, 2, 3]);
      ...
```
PS. If you will use $table->uniquePartial() without extend methods after call uniquePartial(), it works as $table->unique().