One time db scrub with .install file I need to scrub a production db to replace paths in the body field. Being a production database, it needs to happen in a time-sensitive, well-documented way with the solution frozen in code. I'd assume that a .install file would be the best way to do this.

What would a one time install script look like to search the database for "http://mysite.com" and replace with "https://www.mysite.com" in the default body field?
I typically do things like this outside of modules, and instead use a drush script.

The script itself, would go something like


Go into maintenance mode
Do an EntityFieldQuery to get my nids.
Loop through each nid, and
Load the node, and make an entity metadata wrapper
Do the search and replace on the fields
Save the node
Exit maintenance mode


Before and after running the script, I usually do a drush sql-dump.  You can even combine all of this into a single script

#!/bin/bash

drush variable-set -y --always-set maintenance_mode 1
drush sql-dump --result-file=~/db/before.sql
drush scr path/to/my/script.php
drush sql-dump --result-file=~/db/after.sql
drush variable-delete -y --exact maintenance_mode


By doing a drush script, you can really ensure that the task runs when you want it to, and you aren't bound by execution time limits.  I also find it easier to debug.

That said, you should just be able to use Pathologic to rewrite the URLs.  Install/enable it, and add it to your text formats, and configure to do the path fixups.