31 lines
974 B
Bash
Executable file
31 lines
974 B
Bash
Executable file
#!/bin/sh
|
|
# Reset databases and migrations, for development only
|
|
|
|
[ -f manage.py ] || exit $1
|
|
|
|
echo "\033[0;31mWARNING"
|
|
while true; do
|
|
read -p "Do you wish to continue destroy all databases and migrations? (yes/no) " yn
|
|
case $yn in
|
|
[Yy]* ) break;;
|
|
[Nn]* ) exit;;
|
|
esac
|
|
done
|
|
|
|
psql $* postgres -c "DROP DATABASE IF EXISTS neodb;" || exit $?
|
|
|
|
psql $* postgres -c "DROP DATABASE IF EXISTS test_neodb;" || exit $?
|
|
|
|
psql $* postgres -c "CREATE DATABASE neodb ENCODING 'UTF8' LC_COLLATE='en_US.UTF-8' LC_CTYPE='en_US.UTF-8' TEMPLATE template0;" || exit $?
|
|
|
|
psql $* neodb -c "CREATE EXTENSION hstore WITH SCHEMA public;" || exit $?
|
|
|
|
find -type d -name migrations | xargs rm -rf
|
|
|
|
python3 manage.py makemigrations mastodon users books movies games music sync management collection catalog journal social || exit $?
|
|
|
|
python3 manage.py migrate || exit $?
|
|
|
|
psql $* neodb -c "CREATE DATABASE test_neodb WITH TEMPLATE neodb;" || exit $?
|
|
|
|
python3 manage.py check
|