Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
We don't use the prefix on index names
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed May 16, 2017
commit 1951c88bdcc201078968613743229e4d97204855
10 changes: 4 additions & 6 deletions lib/private/App/CodeChecker/DatabaseSchemaChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,12 @@ public function analyse($appId) {

// Index names
foreach ($table->declaration->index as $index) {
if (strpos($index->name, '*dbprefix*') !== 0) {
$warnings[] = 'Database schema warning: name of index ' . $index->name . ' on table ' . $table->name . ' does not start with *dbprefix*';
}
$indexName = substr($index->name, strlen('*dbprefix*'));
if (strpos($indexName, '*dbprefix*') !== false) {
$warnings[] = 'Database schema warning: *dbprefix* should only appear once in name of index ' . $index->name . ' on table ' . $table->name;
$hasPrefix = strpos($index->name, '*dbprefix*');
if ($hasPrefix !== false && $hasPrefix !== 0) {
$warnings[] = 'Database schema warning: *dbprefix* should only appear at the beginning in name of index ' . $index->name . ' on table ' . $table->name;
}

$indexName = $hasPrefix === 0 ? substr($index->name, strlen('*dbprefix*')) : $index->name;
if (strlen($indexName) > 27) {
$errors[] = 'Database schema error: Name of index ' . $index->name . ' on table ' . $table->name . ' is too long (' . strlen($tableName) . '), max. 27 characters + *dbprefix* allowed';
}
Expand Down