Feature: #101553 - Auto-create DB fields from TCA columns

See forge#101553

Description

The TYPO3 v13 Core strives to auto-create database columns derived from TCA columns definitions without explicitly declaring them in ext_tables.sql.

Creating "management" fields like uid, pid automatically derived from TCA ctrl settings is available for a couple of Core versions already, the Core now extends this to single TCA columns.

As a goal, extension developers should not need to maintain a ext_tables.sql definition for casual table columns anymore, the file can vanish from extensions and the Core takes care of creating fields with sensible defaults.

Of course, it is still possible for extension authors to override single definitions in ext_tables.sql files in case they feel the Core does not define them in a way the extension author wants: Explicit definition in ext_tables.sql always take precedence over auto-magic.

New TCA config option dbFieldLength

For fields of type select a new TCA config option dbFieldLength has been introduced. It contains an integer value that is applied to varchar fields (not text) and defines the length of the database field. It will not be respected for fields that resolve to an integer type. Developers who wish to optimize field length can use dbFieldLength for type=select fields to increase or decrease the default length the Core comes up with.

Example:

// will result in SQL text field
'config' => [
    'itemsProcFunc => 'something',
],

// will result in SQL varchar field length for 200 characters
'config' => [
    'itemsProcFunc => 'something',
    'dbFieldLength' => 200,
],
Copied!

Impact

Extension authors should start removing single column definitions from ext_tables.sql for extensions being compatible with TYPO3 v13 and up.

If all goes well, the database analyzer will not show any changes since the Core definition is identical to what has been defined in ext_tables.sql before.

In various cases though, the responsible class DefaultTcaSchema may come to different conclusions than the extension author. Those cases should be reviewed by extension authors one-by-one: Most often, the Core declares a more restricted field, which is often fine. In some cases though, the extension author may know the particular field definition better than the Core default, and may decide to keep the field definition within ext_tables.sql.

Columns are auto-created for these TCA columns types:

  • type = 'category' - Core v12 already
  • type = 'datetime' - Core v12 already
  • type = 'slug' - Core v12 already
  • type = 'json' - Core v12 already
  • type = 'uuid' - Core v12 already
  • type = 'file' - new with Core v13
  • type = 'email' - new with Core v13
  • type = 'check' - new with Core v13
  • type = 'folder' - new with Core v13
  • type = 'imageManipulation' - new with Core v13
  • type = 'language' - new with Core v13
  • type = 'group' - new with Core v13
  • type = 'flex' - new with Core v13
  • type = 'text' - new with Core v13
  • type = 'password' - new with Core v13
  • type = 'color' - new with Core v13
  • type = 'radio' - new with Core v13
  • type = 'link' - new with Core v13
  • type = 'inline' - new with Core v13
  • type = 'number' - new with Core v13
  • type = 'select' - new with Core v13

See Breaking: DateTime column definitions for a change in the datetime column definition calculation.