You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-1Lines changed: 23 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,7 @@ This package is currently in a pre-release beta, please use with caution and ope
15
15
-[Sparse Tables](#sparse-tables)
16
16
-[Shard Keys](#shard-keys)
17
17
-[Sort Keys](#sort-keys)
18
+
-[Unique Keys](#unique-keys)
18
19
-[Series Timestamps](#series-timestamps)
19
20
-[Computed Columns](#computed-columns)
20
21
-[Testing](#testing)
@@ -214,7 +215,6 @@ Schema::create('table', function (Blueprint $table) {
214
215
215
216
$table->sortKey(['f_name', 'l_name']);
216
217
});
217
-
218
218
```
219
219
220
220
Sort keys by default works only for `asc` sort queries. If you would like to create a sort key with `desc` order, you can set the key direction.
@@ -231,6 +231,28 @@ Schema::create('table', function (Blueprint $table) {
231
231
});
232
232
```
233
233
234
+
### Unique Keys
235
+
236
+
You can add an `unique key` to your tables using the standalone `unique` method, or fluently by appending `unique` to the column definition.
237
+
238
+
> **Note:**
239
+
> SingleStore requires that the shard key is contained within an unique key. This means that in most cases you can't use the fluent api as you will likely need to specify more than one column. This restriction does not apply to reference tables.
240
+
241
+
```php
242
+
Schema::create('table', function (Blueprint $table) {
243
+
$table->string('key');
244
+
$table->string('val');
245
+
246
+
$table->shardKey('key');
247
+
$table->unique(['key', 'val']);
248
+
});
249
+
250
+
Schema::create('table', function (Blueprint $table) {
251
+
$table->reference();
252
+
$table->string('name')->unique();
253
+
});
254
+
```
255
+
234
256
### Series Timestamps
235
257
To denote a column as a series timestamp, use the `seriesTimestamp` column modifier.
0 commit comments