Feature: #95061 - Auto creation of MM tables from TCA

See forge#95061

Description

TCA table column fields that define ['config']['MM'] can omit specification of the intermediate mm table layout in ext_tables.sql. The TYPO3 database analyzer takes care of proper schema definition.

This feature has been implemented to simplify developers life and to enable the TYPO3 core to handle those schema details since many extensions tend to specify incomplete or broken mm table schema definitions when dealing with this complex area.

Extensions are strongly encouraged to drop ext_tables.sql CREATE TABLE definitions for those intermediate tables referenced by TCA table columns. Dropping these definitions allows the core to adapt and migrate definitions if needed.

Impact

Extension developers don't need to deal with ext_tables.sql definitions of "mm" tables anymore. The TYPO3 schema analyzer creates the intermediate schema depending on TCA field definition. The schema analyzer tries to apply default specifications if possible. Single ext_tables.sql definitions take precedence, though.

In practice, suppose the "local" side of a mm table is defined as such in TCA:

...
'columns' => [
    ...
    'myField' => [
        'label' => 'myField',
        'config' => [
            'type' => 'group',
            'foreign_table' => 'tx_myextension_myfield_child',
            'MM' => 'tx_myextension_myfield_mm',
        ]
    ],
    ...
],
...

Until now, a schema definition similar to this had to be in place in ext_tables.sql:

CREATE TABLE tx_myextension_myfield_mm (
    uid_local int(11) DEFAULT '0' NOT NULL,
    uid_foreign int(11) DEFAULT '0' NOT NULL,
    sorting int(11) DEFAULT '0' NOT NULL,

    KEY uid_local (uid_local),
    KEY uid_foreign (uid_foreign)
);

This section can and should be dropped. Indicators a schema definition is affected by this:

  • A table column TCA config defines MM with type='select', type='group' or type='inline'.

  • The "MM" intermediate table has no TCA table definition (!).

  • ext_tables.sql specifies a table with fields uid_local and uid_foreign.

The schema analyzer takes care of further possible fields apart from uid_local and uid_foreign, like sorting, sorting_foreign, tablenames, fieldname and uid if necessary, depending on "local" side of the TCA definition.

In general, in case an extension got that definition right up until now, the schema analyzer should not drop or add any additional fields automatically when removing these sections from ext_tables.sql. Developers are strongly encouraged to drop affected CREATE TABLE definitions from ext_tables.sql and to verify the install tool schema migrator acts as expected. The core takes care of these specifications from now on and may add adaptions or migrations to streamline further details in the future.