Skip to content

Instantly share code, notes, and snippets.

@ivanrosolen
Created September 7, 2017 06:25
Show Gist options
  • Save ivanrosolen/120fc34ceb65b0012370859b4830b45f to your computer and use it in GitHub Desktop.
Save ivanrosolen/120fc34ceb65b0012370859b4830b45f to your computer and use it in GitHub Desktop.
Simple SH migration
#!/bin/bash
echo "Host:"
read db_host
echo "User:"
read db_user
echo "Password:"
read db_pwd
echo "Database:"
read db_database
done_files=`cat done_files.txt`
for sql_file in *.sql; do
if echo $done_files | grep -q -w "$sql_file"; then
echo "."
else
echo "$sql_file"
mysql -h $db_host -u $db_user -p$db_pwd $db_database < $sql_file
echo "$sql_file" >> done_files.txt
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment