Skip to content

Commit e99f68c

Browse files
authored
Add empty Sort Key support (#36)
* Add empty sort key support & test
1 parent 5e8f817 commit e99f68c

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,16 @@ Schema::create('table', function (Blueprint $table) {
306306
});
307307
```
308308

309+
However, you may want to tune it without setting a column as sort key. You can do that by creating an empty `sortKey` definition:
310+
311+
```php
312+
Schema::create('table', function (Blueprint $table) {
313+
$table->string('name');
314+
315+
$table->sortKey()->with(['columnstore_segment_rows' => 100000]);
316+
});
317+
```
318+
309319
### Unique Keys
310320

311321
You can add an `unique key` to your tables using the standalone `unique` method, or fluently by appending `unique` to the column definition.

src/Schema/Blueprint/ModifiesIndexes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function shardKey($columns)
2323
* @param $direction
2424
* @return \Illuminate\Support\Fluent
2525
*/
26-
public function sortKey($columns, $direction = 'asc')
26+
public function sortKey($columns = null, $direction = 'asc')
2727
{
2828
$command = $this->indexCommand('sortKey', $columns, 'sortKeyDummyName');
2929
$command->direction = $direction;

tests/Hybrid/CreateTable/SortKeysTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,20 @@ public function it_adds_a_sort_key_with_with_statement()
168168
);
169169
}
170170

171+
/** @test */
172+
public function it_adds_an_empty_sort_key_with_with_statement()
173+
{
174+
$blueprint = $this->createTable(function (Blueprint $table) {
175+
$table->string('name');
176+
$table->sortKey()->with(['columnstore_segment_rows' => 100000]);
177+
});
178+
179+
$this->assertCreateStatement(
180+
$blueprint,
181+
'create table `test` (`name` varchar(255) not null, sort key() with (columnstore_segment_rows=100000))'
182+
);
183+
}
184+
171185
/** @test */
172186
public function it_adds_a_sort_key_fluent_with_with_statement()
173187
{

0 commit comments

Comments
 (0)