Relocating the files directory

Trying best practices I occasionally move the files directory from DRUPAL_ROOT/files/my-site.com to DRUPAL_ROOT/sites/my-sites/files

Doing this has some implications for the files table content. All file-path are pointing to the wrong location.

Quick solution for this is an mysql replace update query.

select replace(filepath, 'files/my-site/', 'sites/my-site/files/') from files;
# update files set filepath=replace(filepath, 'files/my-site/', 'sites/my-site/files/')"

Or through drush

drush sql query "select replace(filepath, 'files/my-site/', 'sites/my-site/files/') from files"
# drush sql query "update files set filepath=replace(filepath, 'files/my-site/', 'sites/my-site/files/')"

See http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_re... for more examples