Skip to content

Commit 3d08f9e

Browse files
authored
Merge pull request #6 from cmu-delphi/SD-16
Change database to mySQL
2 parents fbbfadb + f4e5e82 commit 3d08f9e

File tree

12 files changed

+57
-176
lines changed

12 files changed

+57
-176
lines changed

.env.example

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
POSTGRES_DB=postgres_db_name
2-
POSTGRES_USER=postgres_db_user
3-
POSTGRES_PASSWORD=postgres_db_password
4-
POSTGRES_PORT=postgres_db_port
1+
MYSQL_DATABASE=mysql_database
2+
MYSQL_USER=mysql_user
3+
MYSQL_PASSWORD=mysql_password
4+
MYSQL_PORT=mysql_port
5+
MYSQL_HOST=mysql_host
6+
MYSQL_ROOT_PASSWORD=mysql_root_password
57

68
ALLOWED_HOSTS='127.0.0.1,localhost'
79
CORS_ORIGIN_WHITELIST='http://127.0.0.1:3000,http://localhost:3000'

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ FROM python:3.10.8-alpine
33
ENV PYTHONDONTWRITEBYTECODE=1
44
ENV PYTHONUNBUFFERED=1
55
RUN addgroup -S python && adduser -S python -G python
6+
RUN apk update
7+
RUN apk add musl-dev mariadb-dev gcc
8+
RUN apk add graphviz-dev
69
RUN pip install -U pipenv
710
USER python
811
WORKDIR /home/python

Pipfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ name = "pypi"
66
[packages]
77
django = "*"
88
django-filter = "*"
9-
psycopg2-binary = "*"
109
django-extensions = "*"
1110
pillow = "*"
1211
pre-commit = "*"
@@ -20,8 +19,8 @@ pygraphviz = "*"
2019
django-bootstrap-v5 = "*"
2120
factory-boy = "*"
2221
linkpreview = "*"
23-
pymemcache = "*"
2422
django-redis = "*"
23+
mysqlclient = "*"
2524

2625
[dev-packages]
2726
flake8 = "*"

Pipfile.lock

Lines changed: 24 additions & 87 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker-compose.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ version: '3.8'
33
services:
44

55
db:
6-
image: postgres:latest
6+
image: mysql:latest
77
container_name: signal_documentation-db
88
restart: always
99
env_file:
1010
- ./.env
1111
environment:
12-
POSTGRES_DB: ${POSTGRES_DB}
13-
POSTGRES_USER: ${POSTGRES_USER}
14-
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
15-
POSTGRES_HOST: ${POSTGRES_HOST}
12+
MYSQL_DATABASE: ${MYSQL_DATABASE}
13+
MYSQL_USER: ${MYSQL_USER}
14+
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
15+
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
1616
volumes:
17-
- postgres:/var/lib/postgresql/data
17+
- mysql:/var/lib/mysql/
1818
ports:
19-
- "5432:5432"
19+
- "3306:3306"
2020

2121
webapp:
2222
build: .
@@ -45,5 +45,5 @@ services:
4545
- "6379:6379"
4646

4747
volumes:
48-
postgres:
48+
mysql:
4949
webapp:

src/base/migrations/0001_initial.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by Django 4.2 on 2023-05-09 10:39
1+
# Generated by Django 4.2.2 on 2023-06-13 11:51
22

33
from django.db import migrations, models
44

@@ -15,7 +15,7 @@ class Migration(migrations.Migration):
1515
name='Link',
1616
fields=[
1717
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18-
('link_type', models.CharField(choices=[('api_documentation', 'API Documentation'), ('dua', 'DUA'), ('interpreting_mask', 'Interpreting mask use in context'), ('question_text', 'Question text'), ('survey_details', 'Survey details'), ('survey_documentation', 'Survey documentation'), ('technical_description', 'Technical description'), ('wave_10_revision', 'Wave 10 revision updates'), ('wave_11_revision', 'Wave 11 revision updates'), ('other', 'Other')], help_text='Link type', max_length=128, unique=True)),
18+
('link_type', models.CharField(choices=[('api_documentation', 'API Documentation'), ('dua', 'DUA'), ('interpreting_mask', 'Interpreting mask use in context'), ('question_text', 'Question text'), ('survey_details', 'Survey details'), ('survey_documentation', 'Survey documentation'), ('technical_description', 'Technical description'), ('wave_10_revision', 'Wave 10 revision updates'), ('wave_11_revision', 'Wave 11 revision updates'), ('other', 'Other')], help_text='Link type', max_length=128)),
1919
('url', models.URLField(help_text='Link url', max_length=256, unique=True)),
2020
],
2121
),

src/base/migrations/0002_alter_link_link_type.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/datasources/migrations/0001_initial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by Django 4.2 on 2023-05-09 10:39
1+
# Generated by Django 4.2.2 on 2023-06-13 11:51
22

33
from django.db import migrations, models
44
import django.db.models.deletion

src/signal_documentation/settings.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@
116116

117117
DATABASES = {
118118
'default': {
119-
'ENGINE': 'django.db.backends.postgresql',
120-
'NAME': os.environ.get('POSTGRES_DB', None),
121-
'USER': os.environ.get('POSTGRES_USER', None),
122-
'PASSWORD': os.environ.get('POSTGRES_PASSWORD', None),
123-
'HOST': os.environ.get('POSTGRES_HOST', 'localhost'),
124-
'PORT': os.environ.get('POSTGRES_PORT', 5432),
119+
'ENGINE': 'django.db.backends.mysql',
120+
'NAME': os.environ.get('MYSQL_DATABASE', None),
121+
'USER': os.environ.get('MYSQL_USER', None),
122+
'PASSWORD': os.environ.get('MYSQL_PASSWORD', None),
123+
'HOST': os.environ.get('MYSQL_HOST', 'localhost'),
124+
'PORT': os.environ.get('MYSQL_PORT', 3306),
125125
}
126126
}
127127

src/signals/migrations/0001_initial.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by Django 4.2 on 2023-05-09 10:39
1+
# Generated by Django 4.2.2 on 2023-06-13 11:51
22

33
from django.db import migrations, models
44
import django.db.models.deletion
@@ -22,6 +22,7 @@ class Migration(migrations.Migration):
2222
],
2323
options={
2424
'verbose_name_plural': 'geographies',
25+
'ordering': ['name'],
2526
},
2627
),
2728
migrations.CreateModel(
@@ -44,6 +45,9 @@ class Migration(migrations.Migration):
4445
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
4546
('name', models.CharField(help_text='Name', max_length=128, unique=True)),
4647
],
48+
options={
49+
'ordering': ['name'],
50+
},
4751
),
4852
migrations.CreateModel(
4953
name='Signal',
@@ -63,7 +67,7 @@ class Migration(migrations.Migration):
6367
('has_sample_size', models.BooleanField(default=False, help_text='Has Sample Size')),
6468
('high_values_are', models.CharField(choices=[('bad', 'Bad'), ('good', 'Good'), ('neutral', 'Neutral')], help_text='High values are', max_length=128)),
6569
('available_geography', models.ManyToManyField(help_text='Available geography', to='signals.geography')),
66-
('base', models.ForeignKey(help_text='Signal base', on_delete=django.db.models.deletion.PROTECT, related_name='base_for', to='signals.signal')),
70+
('base', models.ForeignKey(blank=True, help_text='Signal base', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='base_for', to='signals.signal')),
6771
('category', models.ForeignKey(help_text='Signal Category', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='signals', to='signals.signalcategory')),
6872
('links', models.ManyToManyField(help_text='Signal links', related_name='signals', to='base.link')),
6973
('pathogen', models.ForeignKey(help_text='Pathogen/Disease Area', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='signals', to='signals.pathogen')),

0 commit comments

Comments
 (0)