简体   繁体   中英

TYPO3 Extension: create database view during installation

In my TYPO3 extension I use a foreign table. I've created 2 views providing data of this table in the manner my extension needs.

The question is - how can these views be created at installation time?

Views defined in " ext_tables.sql " are ingored by installation routine.

I've tried to use file " ext_tables_static+adt.sql ". This variant works only for INSERT statements.

The only thing I've got to work is variant described here using signal slot dispatcher (sounds complicated but it is really not! Provided documentation is very good).

But I can't believe it that there is no native way (like ext_tables.sql ) to solve such problems.

I did some research on this issue some time ago. There was no other way to achive what you want at that time and I doubt there's evolved a new one in the meantime.

  • I ended up using the hook you mentioned and made it read and execute all Configuration/SQL/*.sql from my extension.
  • There is a way to modify SQL schema at runtime but it is limited to the usual CREATE TABLE (pseudo) statements. Use signal TYPO3\\CMS\\Install\\Service\\SqlExpectedSchemaService - tablesDefinitionIsBeingBuilt for this. It is used in TYPO3 core in TYPO3\\CMS\\Core\\Category\\CategoryRegistry::addCategoryDatabaseSchemaToTablesDefinition
  • Maybe TYPO3's switch to doctrine/dbal will change the situation. As you can see , migration's under way…

Be aware that there's no way to teach install tool's database analyzer your views so it will keep nagging you about removing them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM