Skip to content

Commit

Permalink
Merge pull request #26 from LaurierCS/pablo/setup-local-db
Browse files Browse the repository at this point in the history
Setup Local DB and Updated READMEs
  • Loading branch information
marissa-anj authored Nov 7, 2023
2 parents 4da0846 + db78c30 commit 8ca914d
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 14 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/migrate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Django Migrate

on:
push:
branches: [ "main" ]
paths:
- "api/**"

jobs:
build:
runs-on: ubuntu-latest
env:
DEBUG: 0
defaults:
run:
working-directory: ./api/optimeet/
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Migrate Production DB
run: |
python manage.py makemigrations
python manage.py migrate
28 changes: 28 additions & 0 deletions .github/workflows/test_migrations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Django Test Migrations

on:
pull_request:
branches: [ "main" ]
paths:
- "api/*"

jobs:
build:
runs-on: ubuntu-latest
env:
DEBUG: 1
defaults:
run:
working-directory: ./api/optimeet/
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Migrate Local DB Should Not Throw Errors
run: |
python manage.py makemigrations
python manage.py migrate
2 changes: 1 addition & 1 deletion api/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.env
my.cnf
db.sqlite3
**/__pycache__/
6 changes: 5 additions & 1 deletion api/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
## Setup
1. Install dependencies with `pip install -r requirements.txt`.
2. Create `.env` file in base directory with `DEBUG` and `SECRET_KEY` variables.
3. Create `my.cnf` in base directory with variables required to connect to MySQL database.

## Migrate Model Changes
When you make changes to `models.py` files, you need to run the following commands to update your local DB:
1. `python manage.py makemigrations`
2. `python manage.py migrate`

## Run
Run `python manage.py runserver` to start the server.
28 changes: 18 additions & 10 deletions api/optimeet/optimeet/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
SECRET_KEY = os.getenv("SECRET_KEY")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.getenv("DEBUG")
DEBUG = os.getenv("DEBUG") == "1"


ALLOWED_HOSTS = []
Expand Down Expand Up @@ -83,16 +83,24 @@
# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'HOST': os.getenv("DB_HOST"),
'PORT': os.getenv("DB_PORT"),
'NAME': os.getenv("DB_NAME"),
'USER': os.getenv("DB_USER"),
'PASSWORD': os.getenv("DB_PASS"),
if DEBUG == True:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
else:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'HOST': os.getenv("DB_HOST"),
'PORT': os.getenv("DB_PORT"),
'NAME': os.getenv("DB_NAME"),
'USER': os.getenv("DB_USER"),
'PASSWORD': os.getenv("DB_PASS"),
}
}
}

# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
Expand Down
7 changes: 5 additions & 2 deletions web/meetup-facilitator/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# React + Vite
## Setup
1. Install dependencies with `npm i`.
2. Create `.env` file in base directory with the `VITE_CLIENT_ID` variable.

React app created using Vite.
## Run
Run `npm run dev` to start the server.

0 comments on commit 8ca914d

Please sign in to comment.