Skip to content

Commit 4f27948

Browse files
authored
Merge pull request #306 from WoltLab/php-ddl-index-name
Explain that PHP DDL expects an explicit index name
2 parents 2494c81 + 544ff32 commit 4f27948

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

docs/package/database-php-api.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ If it is not present, `DatabaseTable::foreignKeys()` will automatically set one
125125
Indices are represented by `DatabaseTableIndex` objects:
126126

127127
```php
128-
DatabaseTableIndex::create()
128+
DatabaseTableIndex::create('fooID')
129129
->type(DatabaseTableIndex::UNIQUE_TYPE)
130130
->columns(['fooID'])
131131
```
@@ -134,5 +134,6 @@ There are four different types: `DatabaseTableIndex::DEFAULT_TYPE` (default), `D
134134
For primary keys, there is also the `DatabaseTablePrimaryIndex` class which automatically sets the type to `DatabaseTableIndex::PRIMARY_TYPE`.
135135
To drop a index, all of the relevant data to create the index has to be present and the `drop()` method has to be called.
136136

137-
`DatabaseTableIndex::create()` also supports the index name as a parameter.
138-
If it is not present, `DatabaseTable::indices()` will automatically set one based on the index data.
137+
The index name is specified as the parameter to `DatabaseTableIndex::create()`.
138+
It is strongly recommended to specify an explicit name ([WoltLab/WCF#4505](https://github.com/WoltLab/WCF/issues/4505)).
139+
If no name is given, `DatabaseTable::indices()` will automatically set one based on the index data.

0 commit comments

Comments
 (0)