As this migration is a little sketchy, you might want to split it up and make the down migration irreversible:
http://ariejan.net/2008/05/06/the-migration-that-cannot-be-undone-irreversible-migration/