No announcement yet.

Orphaned Custom Entity

  • Filter
  • Time
  • Show
Clear All
new posts

  • Orphaned Custom Entity

    Running version 5.2.5 on CentOS 7 with MariaDB 5.5.56

    I added a custom entity, then add a custom link to that entity in another entity. Somehow the custom entity disappeared from the EntityManager (but is still in the MySQL database as a table) and thereafter the link field cannot be removed in the EntityManager (there is no "remove" link, so it looks like an Espo original field). I checked in a fresh install of EspoCRM and this field name does not exist there, so it is my custom link field, not Espo-original.

    Now, "rebuild backend" does not work. Adding/removing any field from any entity throws the an error ("Error while rebuilding database")
    I have not done any modification to the database itself or any code, only worked from within the UI with Entity Manager / Layout Manager.
    No idea how this could have happened. There were 2 admins working at the same time, creating entities and links, so something must have
    occured there.

    In my case, the custom entity added was called "Cont", and a link named "cont" was added to Accounts.
    A table "cont" is present in MySQL. It is not present in the Entity Manager. The custom field "cont" (of type LINK) is still present in the Entity Manager for the Accounts entity. In MySQL, there is a field called "cont_id" which might represent that field (or not?)

    When I try to add an integer field (or any other type of field) to ANY entity, the log file shows:
    ERROR: Fault to rebuild database schema. Details: Unknown database type bit requested, Espo\Core\Utils\Database\DBAL\Platforms\MySqlPlatf orm may not support it.

    I know that the MySQL (actually MariaDB) version I use (5.5.56) does support the "bit" data type.
    (I am not even trying to add a "bit" field - it's an integer field, so no idea where the "bit" problem comes from)

    Enabling DEBUG mode, the log shows two additional lines:

    Espo.NOTICE: E_NOTICE: Undefined index: Cont {"code":8,"message":"Undefined index: Cont","file":"/var/www/html/espocrm/field/application/Espo/Core/Utils/Database/Orm/RelationManager.php","line":111,"context":{"linkNa me":"cont","linkParams":{"type":"belongsTo","for ei gn":"accounts","entity":"Cont","audited":false," is Custom":true},"entityName":"Account" .... snip ...

    Espo.ERROR: API [POST]:/Admin/fieldManager/:scope, Params:Array ( [scope] => Case ) , InputData: {"type":"int","required":false,"dynamicLogicVis ibl e":null,"dynamicLogicRequired":null,"dynamicLog icR eadOnly":null,"name":"test" ... (snip) ...

    The first error shows that there is something wrong with that link field "Cont", pointing from Accounts to an entity "Cont".
    The 2nd error is probably the failure message for adding the test integer field to the "Case" entity.

    Probably there is a bug somewhere in EspoCRM - because it should never happen that an entity is present in the database but not shown in Entity Manager.

    So what can I do now to get the system back to operational state?
    I can not add / modify any fields in Entity Manager now.

    Last edited by pschulz; 11-25-2018, 08:51 AM.