-
Notifications
You must be signed in to change notification settings - Fork 1
/
restart_db.sh
36 lines (31 loc) · 1.02 KB
/
restart_db.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
#!/bin/bash
#
#-----------------------------------
# @autor: Wendell P. Barreto
# @email: [email protected]
# @project: tronco
# @doc: restart_db.sh
# ----------------------------------
while true; do
read -p "Are you using Linux (y or n)? " yn
case $yn in
[Yy]* )
sudo -u postgres psql -c 'DROP DATABASE tronco_db'
sudo -u postgres psql -c 'CREATE DATABASE tronco_db'
sudo -u postgres psql -c 'CREATE USER tronco_admin'
sudo -u postgres psql -c 'GRANT ALL PRIVILEGES ON DATABASE tronco_db TO tronco_admin'
sudo -u postgres psql -d tronco_db -c 'CREATE EXTENSION hstore'
break;;
[Nn]* )
psql -c 'DROP DATABASE tronco_db'
psql -c 'CREATE DATABASE tronco_db'
psql -c 'CREATE USER tronco_admin'
psql -c 'GRANT ALL PRIVILEGES ON DATABASE tronco_db TO tronco_admin'
psql -d tronco_db -c 'CREATE EXTENSION hstore'
break;;
* ) echo "Please answer yes or no.";;
esac
done
python manage.py syncdb
python manage.py collectstatic --noinput
python manage.py migrate