Harden the db:migrate logging script

By creating the file with the `rake db:migrate` output in a fresh
directory we protect ourselves against symlink attacks: an attacker can
no longer try to predict the path we will write to and create a symlink
there, because they cannot create a symlink in the new directory we
create.