Move database copying into its own function in main migration script

Small change to make the main migration script a bit more organized.
There must be two blank lines, not one.