Skip to content

CI: SQLite preserve indexes/FKs when altering an introspected table - #1

Open
fballiano wants to merge 4 commits into
4.4.xfrom
fix/sqlite-alter-table-drops-indexes
Open

CI: SQLite preserve indexes/FKs when altering an introspected table#1
fballiano wants to merge 4 commits into
4.4.xfrom
fix/sqlite-alter-table-drops-indexes

Conversation

@fballiano

Copy link
Copy Markdown
Owner

Internal pull request to run the full CI matrix on the fork for the changes proposed upstream in doctrine#7392. Safe to close once CI has reported.

…spected table

The table-recreation path maps index and foreign-key columns to the
altered table through getDiffColumnNameMap(), which is keyed by the
bare column names (Column::getName()). The index and foreign-key
column accessors of an introspected table return the names in their
quoted form ('"sku"'), so every map lookup missed and the branch
meant to drop indexes referencing dropped columns silently dropped
every index and foreign key of the table instead.

Unquote the column names before the lookup, so only indexes and
foreign keys whose columns were actually dropped are removed.

Signed-off-by: Fabrizio Balliano <fabrizio.balliano@gmail.com>
@fballiano fballiano closed this Jun 10, 2026
@fballiano fballiano reopened this Jun 10, 2026
@fballiano
fballiano force-pushed the fix/sqlite-alter-table-drops-indexes branch 2 times, most recently from 8502adc to abc5d06 Compare June 10, 2026 16:24
…spected table

When the altered table is obtained through the introspection API, its
index and foreign-key column names are marked as quoted, so the legacy
Index::getColumns() / ForeignKeyConstraint::getLocalColumns() accessors
return them in quoted form ('"sku"'). The SQLite table-recreation path
maps those columns to the altered table through getDiffColumnNameMap(),
which is keyed by the unquoted column names, so every lookup missed and
the branch meant to drop indexes referencing dropped columns silently
dropped every index and foreign key (and the primary key) of the table
instead.

Read the referencing column names through the non-deprecated
Index::getIndexedColumns() and
ForeignKeyConstraint::getReferencingColumnNames() accessors and compare
their unquoted identifier values, so the lookup is agnostic of whether
the table was introspected or built in memory.

Add a regression test to SchemaManagerFunctionalTestCase so the
scenario, which is not platform-specific, runs against every platform.

Signed-off-by: Fabrizio Balliano <fabrizio.balliano@gmail.com>
…ospection

The referential actions of a foreign key created without explicit actions
are reported inconsistently across platforms (MariaDB reports RESTRICT,
MySQL reports NO ACTION), so the post-alteration foreign keys are compared
against the pre-alteration introspection instead of the in-memory
definition.
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