Saturday, 31 May 2014

Rename fields machine name in Drupal 7


Drupal 7


You want to change fields machine names in Drupal 7.


If you don't have any content then recommended way is to delete a field and crate a new one, but what if you have already some articles?

Export your database:
mysqldump -u [username] -p [database] > backup.sql
Use sed to replace  your old field name with a new one, make sure that you use the same number of characters in a new name, otherwise it will not work.
sed -i 's/field_random_name/field_better_name/g' baskup.sql
Import it back:
mysql -u [username] -p [database] < backup.sql

No comments:

Post a Comment