-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrefresh_dev.sh
executable file
·58 lines (47 loc) · 1.3 KB
/
refresh_dev.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
#This script will refresh your database fixture and entities.
set -e
destructive=false
ShowUsage()
{
cat << EOF
usage: $0 [-d]
Update database with changes using Doctrine.
OPTIONS:
-d Destructive refresh. *CAUTION* This option will drop the database
and reload data fixtures.
EOF
}
while getopts ":dh" OPTION
do
case $OPTION in
d)
destructive=true
;;
h)
ShowUsage
exit
;;
?)
echo "Unknown option - $OPTION"
ShowUsage
exit
;;
esac
done
echo "Generating entities..."
php app/console generate:doctrine:entities Wishlist
if [ $destructive = true ]; then
echo "Dropping Database..."
php app/console doctrine:schema:drop --force
fi
echo "Updating Database..."
php app/console doctrine:schema:update --force
if [ $destructive = true ]; then
echo "Loading Fixtures..."
sed -i '' 's/# \(DROP PROCEDURE [A-z;]*\)/\1/' src/Wishlist/CoreBundle/DataFixtures/SQL/StoredProcedures.sql
mysql -uroot < src/Wishlist/CoreBundle/DataFixtures/SQL/StoredProcedures.sql
sed -i '' 's/\(DROP PROCEDURE [A-z;]*\)/# \1/' src/Wishlist/CoreBundle/DataFixtures/SQL/StoredProcedures.sql
php app/console doctrine:fixtures:load
fi
exit 0