Skip to content

stirlingv/dcstreethockey

Repository files navigation

dcstreethockey

Clone and run using docker

  1. install_docker
  2. install_docker-compose
  3. fork and clone repo
  4. docker-compose up
  5. Stop that process Ctrl+c
  6. Download test data set
  7. docker-compose run --rm web python manage.py loaddata working-herokudump.json
  8. docker-compose up

Clone and Run in localhost

  1. download postgres
  2. fork and clone repo
  3. activate virtual environment
    • venv is part of python3 base image.
    • cd to dcstreethockey folder
    • python3 -m venv [path to virtual environment folder] (first time only)
    • source [path to virtual environment]/bin/activate
  4. pip install -r requirements.txt
  5. Make sure postgres is running and Database exists
    • brew services start postgresql
    • psql -l
      • if dcstreethockey doesn't exist continue
    • createdb dcstreethockey
    • createuser user
  6. uvicorn dcstreethockey.asgi:application --host 0.0.0.0 --port 8000

Deploy - keeps dev and in sync

  1. ./manage.py makemigrations
  2. ./manage.py migrate
  3. git push origin master

[OUTDATED] Ensure DJANGO_SETTINGS_MODULE is set for production deployments

  1. heroku config:set DJANGO_SETTINGS_MODULE=dcstreethockey.settings.production

Create backup of render database and restore in local postgres instance

  1. In render UI, click on recovery tab, and downlowd the latest sql.gz file
  2. Then run:
psql -U user -d dcstreethockey < ~/Downloads/<<file_name>>.sql

Run local database to render

  1. Get Connection Details:
    • Log in to your Render dashboard and navigate to your PostgreSQL service. Copy the connection string provided, which will be in the format:
   postgres://<username>:<password>@<host>:<port>/<database>
  1. Save your SQL script locally, e.g., db_migration_scripts/insert_matchup.sql.
  2. Run the following command in your terminal, replacing <connection_string> with the actual connection string and path/to/your/script.sql with the path to your SQL script:
psql postgres://<username>:<password>@<host>:<port>/<database> -f path/to/your/script.sql