Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 227
gphilip Avatar asked Oct 24 '22 02:10

gphilip


1 Answers

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)

like image 180
Jani Hartikainen Avatar answered Nov 03 '22 19:11

Jani Hartikainen