#106546TYPO3 Database Analyzer should ignore tables that exist as views.
Description
In one of our project, we have an external database and a few TCA models mapped onto views of that external database (using TYPO3_CONF_VARS TableMapping configuration).
Specifically, we have a configuration like the following:
$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['External'] = [
'dbname' => 'dnmame',
'user' => 'user',
// ...
];
$GLOBALS['TYPO3_CONF_VARS']['DB']['TableMapping'] ??= [];
$GLOBALS['TYPO3_CONF_VARS']['DB']['TableMapping']['sample_view_1'] = 'External';
$GLOBALS['TYPO3_CONF_VARS']['DB']['TableMapping']['sample_view_2'] = 'External';
AND The tables (views) sample_view_1 and sample_view_2 are configured as proper TCA tables.
In TYPO3 10 this worked fine – they’re properly ignored – as it did not have the TCA related schema migration yet, but in TYPO3 13 (possibly earlier) it now tries to create those tables in the foreign database due to the existing TCA configuration, despite them already existing as views (I assume the relevant migrator only looks for tables).
This obviously fails, as you cannot create tables with the same name as an existing view.
I could follow it to the SchemaMigrator, that creates a schema entry for every tables managed by TCA, and in the ConnectionMigrator where the diff is built.
Currently I solve the issue by hooking into the AlterTableDefinitionStatementsEvent event, and just removing all my custom TCA entries. As that event is only used in the install tool, that seems to be fine to me.
But it would be nice to have better control over how things are detected by the Database Analyzer.
Greetings
LP
Reviews 4
Related issues 2
Files 2
History 819
-
Stefan Bürk commented and changed category assigned to Stefan Bürk <span data-processor="relativetime" data-value="2025-04-10T15:58:26+00:00" > 04/10/25, 15:58 </span>
-
Georg Ringer changed status
NewAccepted <span data-processor="relativetime" data-value="2025-04-28T19:31:01+00:00" > 04/28/25, 19:31 </span> -
Markus Klein changed Related to #101235 <span data-processor="relativetime" data-value="2025-07-25T12:02:06+00:00" > 07/25/25, 12:02 </span>
-
Daniel Siepmann commented and changed attached 106546.patch <span data-processor="relativetime" data-value="2026-03-09T07:44:56+00:00" > 03/09/26, 07:44 </span>
We now use the following approach in TYPO3 v13. I don’t provide it as patch on Gerrit, as I don’t believe it has any chance to get merged. (E.g. it exposes DBAL classes in its event). But I want to share it here as diff, for others who might seek for a solution. Also it might help as inspiration for a TYPO3 core solution.
NOTE: We only use
./vendor/bin/typo3 database:updateschema, this approach doesn’t seem to work with TYPO3 native maintenance module.We use this for EXT:aimeos, and the implementation looks like this:
<?php declare(strict_types=1); namespace Vendor\Aimeos\EventListener; use Doctrine\DBAL\Schema\Schema; use TYPO3\CMS\Core\Attribute\AsEventListener; use TYPO3\CMS\Core\Database\Event\AlterSchemasForDiffEvent; final readonly class AlterSchemasForDiffEventListener { #[AsEventListener()] public function __invoke(AlterSchemasForDiffEvent $event): void { $fromSchema = $event->getFromSchema(); $toSchema = $event->getToSchema(); foreach ($toSchema->getTables() as $table) { $tableName = $table->getName(); if ($this->shouldIgnoreTable($tableName)) { $this->removeTable($tableName, $fromSchema, $toSchema); } } } private function shouldIgnoreTable(string $tableName): bool { if (in_array($tableName, $this->getTableNamesToIgnore())) { return true; } foreach ($this->getTableNamePrefixesToIgnore() as $prefixToIgnore) { if (str_starts_with($tableName, $prefixToIgnore)) { return true; } } return false; } /** * @return string[] */ private function getTableNamePrefixesToIgnore(): array { return [ 'madmin_', 'mshop_', ]; } /** * @return string[] */ private function getTableNamesToIgnore(): array { return [ // Added by this extension and maintained by EXT:aimeos 'fe_users_address', // Aimeos tables within TYPO3, not detectable by naming convention. // The suffix is not unique enough. 'fe_users_list', 'fe_users_property_type', 'fe_users_list_type', 'fe_users_property', ]; } private function removeTable( string $tableName, Schema $fromSchema, Schema $toSchema ): void { if ($fromSchema->hasTable($tableName)) { $fromSchema->dropTable($tableName); } if ($toSchema->hasTable($tableName)) { $toSchema->dropTable($tableName); } } } -
Markus Klein commented and changed attached 106546_v13_composer.patch <span data-processor="relativetime" data-value="2026-03-17T17:16:45+00:00" > 03/17/26, 17:16 </span>
Adjusted the patch slightly to use public properties in the event and to be relative to cms-core, for composer patches integration.
-
Gerrit Code Review pushed patch set 1 for main to change 95192 status
AcceptedUnder Review <span data-processor="relativetime" data-value="2026-08-09T21:00:20+00:00" > 08/09/26, 21:00 </span> -
Gerrit Code Review pushed patch set 2 for main to change 95192 <span data-processor="relativetime" data-value="2026-08-09T22:35:45+00:00" > 08/09/26, 22:35 </span>
-
Gerrit Code Review pushed patch set 1 for main to change 95240 <span data-processor="relativetime" data-value="2026-08-11T00:32:20+00:00" > 08/11/26, 00:32 </span>
-
Stefan Bürk changed Related to #110420 <span data-processor="relativetime" data-value="2026-08-11T01:25:43+00:00" > 08/11/26, 01:25 </span>
-
Gerrit Code Review pushed patch set 2 for main to change 95240 <span data-processor="relativetime" data-value="2026-08-11T04:00:58+00:00" > 08/11/26, 04:00 </span>
-
Gerrit Code Review pushed patch set 3 for main to change 95240 <span data-processor="relativetime" data-value="2026-08-11T05:17:36+00:00" > 08/11/26, 05:17 </span>
-
Gerrit Code Review pushed patch set 4 for main to change 95240 <span data-processor="relativetime" data-value="2026-08-11T11:38:29+00:00" > 08/11/26, 11:38 </span>
-
Gerrit Code Review pushed patch set 5 for main to change 95240 <span data-processor="relativetime" data-value="2026-08-11T13:29:35+00:00" > 08/11/26, 13:29 </span>
-
Gerrit Code Review pushed patch set 6 for main to change 95240 <span data-processor="relativetime" data-value="2026-08-11T14:14:17+00:00" > 08/11/26, 14:14 </span>
-
Gerrit Code Review pushed patch set 7 for main to change 95240 <span data-processor="relativetime" data-value="2026-08-14T20:48:58+00:00" > 08/14/26, 20:48 </span>
-
Gerrit Code Review pushed patch set 1 for 14.3 to change 95390 <span data-processor="relativetime" data-value="2026-08-23T14:52:58+00:00" > 08/23/26, 14:52 </span>
-
Gerrit Code Review pushed patch set 1 for 13.4 to change 95391 <span data-processor="relativetime" data-value="2026-08-23T14:53:10+00:00" > 08/23/26, 14:53 </span>
-
Stefan Bürk commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2026-08-23T17:10:09+00:00" > 08/23/26, 17:10 </span>Applied in changeset commit:c9c21e1b4cbff23201c8a05062cc0892291e534b.
-
Markus Klein commented and changed status
ResolvedAccepted <span data-processor="relativetime" data-value="2026-08-23T18:15:32+00:00" > 08/23/26, 18:15 </span>The merged changes now correctly blind the views in “compare DB” actions.
But we still have the problem that VIEWs defined in TCA are created as table, as long as the VIEW does not exist yet in the DB.In that case the event in the core-patch above is still needed, so extensions can remove those VIEWs from being generated.
Worth looking into it. Added it to my list for doctrine/dbal.
Excluding things is general a thing, in old days this could be
archieved with a setting and later with introduction of doctrine/dbal
using the events, which has been removed by doctrine/dbal 4.
Thanks for reporting this. Keeping it as “bug” report for now, albeit
not sure if we keep that as bug or more as a feature. We will see.