#!/bin/bash # Database details DBS=("console_db" "logs_db") DB_OWNER="console_user" # Drop and create databases for DB in "${DBS[@]}"; do sudo -u postgres -H -- psql -c "DROP DATABASE IF EXISTS $DB" sudo -u postgres -H -- psql -c "CREATE DATABASE $DB OWNER $DB_OWNER" done PROJECT_DIR="/home/t0xa/Documents/backend" VENV_DIR="$PROJECT_DIR/.venv" cd "$PROJECT_DIR" || { echo "Project directory not found!"; exit 1; } source "$VENV_DIR/bin/activate" git clean -xf */migrations/ python3 manage.py makemigrations python3 manage.py migrate python3 manage.py migrate --database logs python3 manage.py shell -c " from django.contrib.auth import get_user_model; User = get_user_model(); if not User.objects.filter(email='a@a.ru').exists(): User.objects.create_superuser('a@a.ru', password='T1Rules@123') " deactivate # sudo -u postgres -H -- psql -c "DROP DATABASE console_db" # sudo -u postgres -H -- psql -c "DROP DATABASE logs_db" # sudo -u postgres -H -- psql -c "CREATE DATABASE console_db OWNER console_user" # sudo -u postgres -H -- psql -c "CREATE DATABASE logs_db OWNER console_user" # cd /home/t0xa/Documents/backend # source .venv/bin/activate # # python3 manage.py makemigrations # python3 manage.py migrate # python3 manage.py shell -c "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('a@a.ru', password='T1Rules@123')" # deactivate