Improved python script to generation migration SQL