Database is not updating the changes made in back-end

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ashif Malayil
    Senior Member
    • Dec 2023
    • 171

    Database is not updating the changes made in back-end

    I am unable to create a new field in my instance. As instructed, I tried changing the field maxLength from the database also changed some fields from "Varchar" to "Text" from back-end. However, after making these changes, clearing the cache, and rebuilding, the changes are not being reflected in the database. Please review the attached screenshot for more clarity (screenshot 1&2).

    When i am trying to change it from database itself i'm getting this error? (screenshot 3) What could be causing this issue?​
    Last edited by Ashif Malayil; 09-17-2024, 07:26 AM.
  • victor
    Active Community Member
    • Aug 2022
    • 727

    #2
    In this branch, I gave you a detailed explanation about both methods of solving problem with new fields creation: https://forum.espocrm.com/forum/gene...ate-new-fields.

    Please note that when changing the length of a Varchar field, you must strictly follow the sequence:
    1. In /your-instance-name/custom/Espo/Custom/Resources/metadata/entityDefs/your-entity-name.json set the new required length (screenshot 1).
    2. Next, in phpMyadmin or its analogue, set a similar length for this field (screenshot 2).
    3. Make Rebuild or Hard Rebuild via CLI (it's important via CLI).
    If you get an error 1406: Data too long for column in the second step, then most likely in one of the records the data length of the problem field exceeds the length that you are trying to set in steps 1 and 2. That is why in this case it is better to use the type change from Varchar to Text instead of changing the length, as described in the link above.
    Attached Files
    Last edited by victor; 09-17-2024, 10:01 AM.

    Comment

    • Ashif Malayil
      Senior Member
      • Dec 2023
      • 171

      #3
      victor , the issue is that I'm unable to change all my "Varchar" fields to "Text."
      1. As per the screenshots (1 & 2) I have shared, the field has a maxLength of 60 in the JSON, but in the database, it shows as 150. Why is there a difference? It should change after a rebuild, right?
      2. Fields like salutation_name in the database have a maxLength of 255. I tried to change it, but after rebuilding, it reverts back to 255.
      Last edited by Ashif Malayil; 09-17-2024, 09:31 AM.

      Comment

      • victor
        Active Community Member
        • Aug 2022
        • 727

        #4
        Why is there a difference? It should change after a rebuild, right?
        No, Rebuild or Hard Rebuild via CLI is done at the end. Carefully review the sequence of execution of the instructions. Remember to save your changes after each step.

        the issue is that I'm unable to change all my "Varchar" fields to "Text."
        - In this case, try to do a Hard Rebuild first: https://docs.espocrm.com/administrat.../#hard-rebuild.
        - Then try the option with changing the field type. If the error occurs again, it is better not to touch this field at all and make changes in other fields with Varchar type. Or try to change the length of the Varchar field once again (strictly in the sequence outlined in the instructions) and immediately perform a Hard Rebuild in the third step.​

        Fields like salutation_name in the database have a maxLength of 255. I tried to change it, but after rebuilding, it reverts back to 255
        This means that you have followed the instructions incorrectly (screenshot 1 and 2). It is better not to change system fields in system entities. Perhaps this will cause unexpected problems in the future.
        Attached Files
        Last edited by victor; 09-17-2024, 10:10 AM.

        Comment

        Working...