Last active
November 29, 2016 18:33
-
-
Save Toltar/70a28915d5522ea9883e5db584c11c2f to your computer and use it in GitHub Desktop.
A Bash Script which uses Doctrine to create a update.sql file and executes the query into mysql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Name: Doctrine Update Bash Script | |
# Description: Updates the MySQL database automatically with one script with doctrine! | |
echo "Creating the update.sql file.....\n" | |
./vendor/bin/doctrine-module orm:schema-tool:update --dump-sql >> ./scripts/db/update.sql | |
#Checking if the file exists | |
if [ -f ./scripts/db/update.sql ]; then | |
echo "SUCCESS! File successfully created!\n" | |
echo "Executing the query\n" | |
#To use this run this before using this script: | |
# mysql_config_editor set --login-path=local --hostname=localhost --user=[ENTER USER HERE] --password | |
# NOTE: This will ask for the mysql password after you hit enter on this command | |
# mysql_config_editor manpages: https://docs.oracle.com/cd/E53394_01/html/E54763/mysql-config-editor-1.html | |
mysql --login-path=local [dbname here] < ./scripts/db/update.sql | |
rm ./scripts/db/update.sql | |
echo "Query successfully updated!!" | |
else | |
echo "ERROR: UNABLE TO CREATE update.sql file" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment