Change field type from enum to multiEnum

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Pablo
    Senior Member
    • Aug 2015
    • 177

    Change field type from enum to multiEnum

    Hi,

    We have a enum field that we need to change to multiEnum. We saw this post to change the field type to varchar.

    However, when adapting the same process to our field (enum to multiEnum) and rebuilding, an error occurs in the logs:

    Code:
    ALERT: Rebuild database fault: PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near
    We are changing this:

    Code:
    "cejasPuntaUsada": {
    "type": "enum",
    "required": false,
    "options": [
    "",
    "1",
    "2",
    "3",
    "18"
    ],
    "style": {
    "1": null,
    "2": null,
    "3": null,
    "18": null,
    "": null
    },
    "default": "",
    "isCustom": true
    },
    To this:

    Code:
    "cejasPuntaUsada": {
    "type": "multiEnum",
    "storeArrayValues": true,
    "required": false,
    "options": [
    "",
    "1",
    "2",
    "3",
    "18"
    ],
    "style": {
    "1": null,
    "2": null,
    "3": null,
    "18": null,
    "": null
    },
    "isCustom": true
    },
    Is there something missing?

    Thanks!
  • alter
    Member
    • Apr 2018
    • 57

    #2
    Hi, I would not recommend manually updating schema of the field - this is not a great approach in any kind of system, where it's not built-in functionality. It might work at some point, but it may cause errors as well.

    I would recommend you to create a new multiEnum field and migrate the data from original singleEnum to the new field, then delete the old field.

    Comment

    • Pablo
      Senior Member
      • Aug 2015
      • 177

      #3
      Hi alter ,

      Thanks for your message.

      I was hoping not to create a new field but I will take your advice and do the whole migration to avoid issues.

      Thanks for your help.

      Comment

      • esforim
        Active Community Member
        • Jan 2020
        • 2204

        #4
        I think you also have to edit the field type in the mySQL (or database) too, changing the file code will just 'disable' the validation or visual look. But yes, safe approach would be export and import into a new field... but this might not be possible with multi-enum.

        Comment

        Working...