Upgrade Table and Field Definitions ¶
Each extension in TYPO3 CMS can bring the file
defines which tables and fields the extension needs. Gathering all
thus defines the full set of tables, fields and
indexes of a TYPO3 instance to unfold its full feature set. Some functionality
in the Install Tool can compare the defined set with the current active
database schema and shows options to align those two by adding fields,
removing fields and so on.
When you upgrade to newer versions of TYPO3 CMS or upgrade an extension, the data definition of tables and fields might have changed. The TYPO3 CMS Install Tool will detect such changes.
When you install a new extension, any change to the database is automatically performed. When you upgrade to a new major version of TYPO3 CMS, you should normally go through the Upgrade Wizard, whose first step is to perform all necessary database changes:
When performing smaller updates, after updating extensions or - in general - if you want to check the sanity of your system, you can go to ADMIN TOOLS > Maintenance > Analyze Database Structure :
What this tool does is collating the information from all
files of active extensions and compare it with
the current database structure. It then proposes to perform the necessary changes,
grouped by type: creating new tables, adding new fields to existing
tables, altering existing fields, dropping unused tables and fields.
You can choose which updates you want to perform. You can even decide not to create new fields and tables, although that will very likely break your installation.
More information about the process of upgrading TYPO3 CMS can be found in the Installation and Upgrade Guide .
The ext_tables.sql Files ¶
As mentioned before, all data definition statements are stored in
which may be present in any
The peculiarity is that these files may not always contain a complete and valid SQL data definition. For example, system extension “rsaauth” defines a new table for storing RSA keys:
CREATE TABLE tx_rsaauth_keys ( uid int(11) NOT NULL auto_increment, pid int(11) DEFAULT '0' NOT NULL, crdate int(11) DEFAULT '0' NOT NULL, key_value text, PRIMARY KEY (uid), KEY crdate (crdate) );
This is a complete and valid SQL data definition. However
system extension “css_styled_content” extends the “tt_content”
table with additional fields. It also provides these changes
in the form of a SQL
CREATE TABLE tt_content ( header_position varchar(6) DEFAULT '' NOT NULL, image_compression tinyint(3) unsigned DEFAULT '0' NOT NULL, image_effects tinyint(3) unsigned DEFAULT '0' NOT NULL, image_noRows tinyint(3) unsigned DEFAULT '0' NOT NULL, section_frame int(11) unsigned DEFAULT '0' NOT NULL, spaceAfter smallint(5) unsigned DEFAULT '0' NOT NULL, spaceBefore smallint(5) unsigned DEFAULT '0' NOT NULL, table_bgColor int(11) unsigned DEFAULT '0' NOT NULL, table_border tinyint(3) unsigned DEFAULT '0' NOT NULL, table_cellpadding tinyint(3) unsigned DEFAULT '0' NOT NULL, table_cellspacing tinyint(3) unsigned DEFAULT '0' NOT NULL );
The classes which take care of assembling the complete SQL data
definition will compile all the
for a given table and turn it into a single
statement. If the table already exists, missing fields are isolated
statements are proposed instead.
What this means is that - as an extension developer - you should always
statements in your
files, the system will handle them as needed.