Closed Kaik closed 7 years ago
changing the actual column name in the DB is more difficult than you might think. I tried to do it in blocks (content
-> properties
) and it killed all upgrades to the 1.4.2 release. So don't use the SchemaTool. You will probably have to achieve it with manual SQL. Another option is to leave the DB alone and only change the property names in the object (have to then notate the column name in the entity def).
Ok good to know. I will use SQL I have used it before in InterCom module and I was using Dizkus as an example it worked. Column names were changed using SQL and SchemaTool update was called at the end - I believe it is called only to refresh some internal doctrine mappings - and it is not used to change any column name.
...
$sql = 'UPDATE intercom SET msg_outbox = NOT msg_outbox';
$stmt = $connection->prepare($sql);
$stmt->execute();
...
try {
$this->schemaTool->update(['Zikula\IntercomModule\Entity\MessageEntity']);
} catch (Exception $e) {
$this->addFlash('error', $e);
return false;
}
...
I do not yet know when (which version) I will do this. I need to think about it.
This is mostly done in a way you described using name in colum def.
Most of the entities have entity name in id field for example topic_id, forum_id etc... this can/should be refactored to just id.