Visitar URL original
[ticket/17746] Keep indexes that are dropped and added in one schema change by bonelifer · Pull Request #7093 · phpbb/phpbb · GitHub
Skip to content

[ticket/17746] Keep indexes that are dropped and added in one schema change - #7093

Open
bonelifer wants to merge 1 commit into
phpbb:masterfrom
bonelifer:ticket/17746
Open

bonelifer wants to merge 1 commit into
phpbb:masterfrom
bonelifer:ticket/17746

Conversation

@bonelifer

Copy link
Copy Markdown
Member

Checklist:

  • Correct branch: master for new features; 3.3.x for fixes
  • Tests pass
  • Code follows coding guidelines: master and 3.3.x
  • Commit follows commit message format

Tracker ticket:

https://tracker.phpbb.com/browse/PHPBB-17746

When a migration drops an index and adds it back under the same name with other columns, in one perform_schema_changes() call, the change is lost on 4.0 and the old index stays. Doctrine reports such an index as modified (TableDiff::getModifiedIndexes()), and \phpbb\db\doctrine\comparator::compareTables() rebuilt the diff from the added and dropped indexes only. Each modified index is now added to both lists, its old definition as dropped and its new one as added.

\phpbb\db\tools\doctrine::schema_index_drop() also changes: when a migration drops an index by its unprefixed key name and the table has both that name and the generated prefixed name, the generated one is dropped, since that's the index phpBB created.

This is against master because 3.3.x doesn't use Doctrine for schema changes.

Tests:

  • phpbb_dbal_db_tools_test::test_perform_schema_changes_replaces_index_with_same_name drops and re-adds a unique index with an extra column in one schema change, on the configured database.
  • New phpbb_dbal_doctrine_comparator_test, with no database: the modified index produces SQL on the MySQL, PostgreSQL and SQLite platforms, and the legacy key name drops the generated index.

Claude ran every phpbb_dbal_ test (247) on SQLite, MySQL 8.0 and PostgreSQL 16, in throwaway containers, with PHP 8.4. They all pass; the only skips are ones that already exist (long index names, and database features like multi-insert). Without the fix, the five new tests fail on SQLite, and the database test fails on MySQL and PostgreSQL too. The code sniffer finds nothing in the changed files.


Investigated and written by Claude on behalf of William Jacoby (bonelifer).

🤖 Generated with Claude Code

…change

Doctrine reports an index dropped and added again with the same name but
other columns as a modified index. The comparator rebuilt the table diff
from the added and dropped indexes only, so the change was lost and the
old index stayed. Add each modified index as dropped and added.

When a migration drops an index by its unprefixed key name and the table
also has the generated, prefixed name, drop the generated index.

PHPBB-17746
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant