fix(migration): accept ITable from getTable() in addMailboxKey - #13459
fix(migration): accept ITable from getTable() in addMailboxKey#13459ChristophWurst wants to merge 5 commits into
Conversation
OCP's ISchemaWrapper::getTable() now returns OCP\DB\Schema\ITable instead of Doctrine\DBAL\Schema\Table on newer server versions. Widen the addMailboxKey() parameter types to Table|ITable so the migration works on both, and suppress the not-yet-vendored ITable stub in psalm. Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com>
|
/backport to stable5.11 |
|
/backport to stable5.10 |
|
There are more changes necessary to make Psalm happy, but there are also legit gaps.
|
This should still work, since getForeignKeys is not implemented in Table, it's forwarding the method call to the DBAL Table via the
Same, modifyColumn in OCP\DB\Schema, has some more strict type hints but at runtime this should still work as it is just forwarding the arguments. |
Signed-off-by: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com>
Signed-off-by: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com>
|
Looking at the latest psalm issues, I probably went to far for requiring non empty lowercase string for index. I will change that |
Signed-off-by: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com>
Signed-off-by: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com>
|
Last psalm issue seems to be a false positive from psalm |
| */ | ||
| foreach ($mailboxesTable->getIndexes() as $index) { | ||
| if ($index->isUnique() && $index->spansColumns(['account_id', 'name'])) { | ||
| if ($index->isUnique() && $index->getColumns() === ['account_id', 'name']) { |
There was a problem hiding this comment.
Would be nice to also expose spansColumns because it ignores the order.
As hardening we should array diff expected and actual columns and test for an empty array.
There was a problem hiding this comment.
But the other matters. An index on [a,b] is very different from [b,a].
For this specific case we only need to catch the condition where the ordering is [account_id, name], right?
OCP's ISchemaWrapper::getTable() now returns OCP\DB\Schema\ITable instead of Doctrine\DBAL\Schema\Table on newer server versions. Widen the addMailboxKey() parameter types to Table|ITable so the migration works on both, and suppress the not-yet-vendored ITable stub in psalm.
Assisted-by: Claude:claude-opus-4-8
Ref nextcloud/server#63013
馃 AI (if applicable)