Task #56964
closed
Extend SqlSchemaMigrationService to support (basic) ALTER TABLE
Added by Stefan Neufeind over 10 years ago.
Updated over 7 years ago.
Description
In typo3/sysext/install/Classes/Service/SqlSchemaMigrationService.php
currently only "CREATE TABLE" is supported. That's used for the normal SQL-statements where fields get defined - or have their type/defaults/... changed by subsequent CREATE TABLE-statements.
For cases like SQL generated by extension-builder it would be great to also have a change to use ALTER TABLE to drop a certain key or field. For that only basic ALTER TABLE-support would be needed.
I don't understand the (real) use case. If you do not define a column in the CREATE TABLE statement (or one of its "extension", adding other fields), any existing column will be suggested to be renamed as zzz_<column_name> in Install Tool, which lets you then safely remove them, again with the Install Tool.
As such I don't see a high need to actively support ALTER TABLE statements.
The only use-case would be to be able to remove existing columns like deleted or hidden or so. You can deactivate them (modify TCA) which helps get the desired effect (for example have records permananetly removed upon delete or offering no disabled/hidden-functionality). But you can not get rid of those DB-columns.
extension_builder currently autogenerated deleted, disabled/hidden and starttime/endtime. But I've also submitted a feature for review there to allow to not generate those fields in the first place (#56965).
I've seen that, but as said, deactivating them in TCA is not enough, if you remove them from the CREATE TABLE statements in the first place, they will be suggested for removal in Install Tool, without any change needed.
Yes, but often you can't just remove the CREATE TABLE. Currently extension-builder autogenerates things like starttime/endtime. And even if you remove from TCA they'll still be in DB. (I've sent a patch to extension-builder for review. If interested please review - not that big actually #56965).
The other case is that not your extension but some other or core provided the CREATE TABLE and there is nothing you can do about it.
- Target version set to 7 LTS
- Category changed from Install Tool to 1601
- Target version changed from 7 LTS to 8 LTS
- Category changed from 1601 to Install Tool
- Status changed from New to Closed
the solution here is to auto-create most of the ext_tables.sql from TCA, effectively dropping most ext_tables.sql. this work will be done in new tickets.
Also available in: Atom
PDF