#!/bin/bash
#

set -e  #  Exit immediately if any command exits with a non-zero status

activate_venv() {
    source env/bin/activate
}

update_db() {  # Create the database. This also populates it with some goals and votes from the default rewards.py
    export FLASK_APP=ownchatbot
    if python -m flask update-db; then
        echo "Database updated successfully."
    else
        echo "Failed to update the database. Please check for errors."
        exit 1  # Exit the script with a non-zero status
    fi
}

activate_venv
update_db
deactivate
