Fixed the deploy script to wait for database availability