ConnectionMigrator does not handle renamed columns
in our extension events2 I have renamed the column "events" to "event", but "Database analyzer" can not detect that change. So currently I have to rename that column on my own on DB directly.
SchemaDiff class of Doctrine DBAL compares the arrays of addedColumns against removedColumns. If some Options are the same the SchemaDiff class moves that difference to renamedColumns and DELETEs the entries from addedColumns and removedColumns.
In ConnectionManager you only collect the values of addedColumns (Method: getNewFieldUpdateSuggestions) and removedColumns (Method: getUnusedFieldUpdateSuggestions), but there is no check against renamedColumns.
In the meanwhile I have 12 tables incl. some TYPO3 tables like sys_file_metadata and pages which could not be migrated because of renamedColumns.
[BUGFIX] InstallTool: handle column renames in database compare
When the Doctrine SchemaMigrator detects an added column and a removed
column that only differ by name but not by configuration these separate
changes get optimized into a column rename operation.
Deoptimize these renames into distinct add/drop column operations to
keep handling of columns consistent when multiple columns change at the
Tested-by: TYPO3com <email@example.com>
Reviewed-by: Susanne Moog <firstname.lastname@example.org>
Tested-by: Susanne Moog <email@example.com>
Reviewed-by: Christian Kuhn <firstname.lastname@example.org>
Tested-by: Christian Kuhn <email@example.com>
#1 Updated by Christian Kuhn almost 3 years ago
Stefan, I think that's not possible. The schema analyzer compares definition (ext_tables) with current db state, but it does not compare a "previous" definition with definition "now". There is no other state.
Saying "hey, you want to have field 'event', it is not in db, but i found a similar field 'events' let's use that instead" is guess work that will immediately fail.
What you want / need is migration. This needs a concept anyway.
#3 Updated by Christian Kuhn almost 3 years ago
Ok, slightly misunderstood this issue. The problem is that fields which are detected by doctrine as "rename" are NOT added later, so those fields are missing and can not be added by install tool schema analyzer. this is clearly a bug that needs to be fixed.
however, i think, we must NOT use the renaming functionality of doctrine, but switch those suggestions to add instead, or disable the rename integration.