2022-12-13 18:12:43 +00:00
#!/bin/sh
# Reset databases and migrations, for development only
[ -f manage.py ] || exit $1
2022-12-13 16:33:58 -05:00
echo "\033[0;31mWARNING: this script will destroy all neodb databases and migrations"
2022-12-13 18:12:43 +00:00
while true; do
2022-12-13 16:33:58 -05:00
read -p "Do you wish to continue? (yes/no) " yn
2022-12-13 18:12:43 +00:00
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
2022-12-16 09:53:06 -05:00
python3 manage.py makemigrations auth mastodon users books movies games music sync management collection common sync management timeline catalog journal social || exit $?
2022-12-13 18:12:43 +00:00
python3 manage.py migrate || exit $?
psql $* neodb -c "CREATE DATABASE test_neodb WITH TEMPLATE neodb;" || exit $?
python3 manage.py check