mysqldoctrine-orm

Renaming field in Doctrine 2 without losing data


This seems to be something obvious but I simply can't find info by googling. How can I rename a field in Doctrine2 without losing data (i.e. dropping old field and creating new one)?

Thanks!


Solution

  • Manually run an SQL query against your DB to rename the field.

    Although the Doctrine 2 schema-tool exists, it is not meant to be used for modifying production databases and as such does not necessarily perform operations in a way which does not lose data (plus it would be kind of tricky to detect something like a column rename 100% accurately just based on the metadata for the entities)