fix(db): Create replacement index where original index is missing#51439
fix(db): Create replacement index where original index is missing#51439AndyScherzinger merged 1 commit intomasterfrom
Conversation
|
/backport to stable31 |
|
/backport to stable30 |
| $table = $schema->getTable($toReplaceIndex['tableName']); | ||
| // If none of the previous indices existed we have to add the index | ||
| if (array_filter($toReplaceIndex['oldIndexNames'], static fn (string $indexName) => $table->hasIndex($indexName)) === []) { | ||
| $missingIndices[] = [ |
There was a problem hiding this comment.
I saw an entry in the Nextcloud log saying "Undefined array key "dropUnnamedIndex" at /knickrehm/www/cloud/core/Command/Db/AddMissingIndices.php#79" after applying this fix. From what I see, this array should contain a value for the key "dropUnnamedIndex" or 79 should not expect a value to exist for that key.
come-nc
left a comment
There was a problem hiding this comment.
Not sure I get it, there was a code path for when all old names existed, you added one for when non of them exists, but there is still an issue if only some of them exists, no?
Why not simply ignore the existing, add the new one and then drop the old ones if they exist?
|
Actually fair point. I'll look into that! |
|
@come-nc thanks a lot for the suggestion. The code is a lot simpler now! |
Signed-off-by: Christoph Wurst <[email protected]>
063c77f to
29161c0
Compare
Summary
While working on #51438 I noticed that replacement indexes are not created if the old indexes don't exist. This can happen in the following deployment
Before: old and new index were missing
After: new index is added
The setup check has already reported the affected indices as missing, but they were never added.
TODO
Checklist