Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare database deploiement #31

Merged
merged 3 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion api/.env.cicd
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ FRONTEND_URL=http://localhost:5173
BACKEND_URL=http://127.0.0.1:5173
BACKEND_HOST=127.0.0.1:5173
DEBUG=True
SECRET_KEY=django-insecure-^=xy+akjdagtjisch+_5fku9!1aw)hhf_&feny8r3@6ds%rds
SECRET_KEY=django-insecure-^=xy+akjdagtjisch+_5fku9!1aw)hhf_&feny8r3@6ds%rds
PRODUCTION=False
17 changes: 14 additions & 3 deletions api/masteriq/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.0/ref/settings/
"""

from distutils.util import strtobool
from pathlib import Path
import os
from dotenv import load_dotenv
Expand All @@ -27,7 +27,7 @@
SECRET_KEY = os.getenv('SECRET_KEY')

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

ALLOWED_HOSTS = [
os.getenv('BACKEND_HOST')
Expand Down Expand Up @@ -86,13 +86,24 @@

# Database
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
if os.getenv('PRODUCTION') == 'True':
DATABASES = {
'default': {
'ENGINE': os.getenv('DB_ENGINE'),
'NAME': os.getenv('DB_NAME'),
'USER': os.getenv('DB_USER'),
'PASSWORD': os.getenv('DB_PASSWORD'),
'HOST': os.getenv('DB_HOST'),
'PORT': os.getenv('DB_PORT'),
}
}



# Password validation
Expand Down
2 changes: 1 addition & 1 deletion api/masteriqapp/migrations/0002_auto_20240303_1147.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def load_initial_data(apps, schema_editor):

class Migration(migrations.Migration):
dependencies = [
('masteriqapp', '0001_initial'),
('masteriqapp', '0003_alter_category_users'),
]

operations = [
Expand Down
2 changes: 1 addition & 1 deletion api/masteriqapp/migrations/0003_alter_category_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class Migration(migrations.Migration):

dependencies = [
('masteriqapp', '0002_auto_20240303_1147'),
('masteriqapp', '0006_alter_option_question_alter_option_text_and_more'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

Expand Down
2 changes: 1 addition & 1 deletion api/masteriqapp/migrations/0005_category_image_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class Migration(migrations.Migration):

dependencies = [
('masteriqapp', '0003_alter_category_users'),
('masteriqapp', '0002_auto_20240303_1147'),
]

operations = [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 5.0.2 on 2024-03-18 20:09

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


class Migration(migrations.Migration):

dependencies = [
('masteriqapp', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='option',
name='question',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='options', to='masteriqapp.question'),
),
migrations.AlterField(
model_name='option',
name='text',
field=models.CharField(max_length=1024),
),
migrations.AlterField(
model_name='question',
name='text',
field=models.CharField(max_length=1024),
),
]
2 changes: 1 addition & 1 deletion api/masteriqapp/models/Option.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


class Option(models.Model):
text = models.CharField(max_length=255)
text = models.CharField(max_length=1024)
is_correct = models.BooleanField()
question = models.ForeignKey(Question, related_name='options', on_delete=models.CASCADE)

Expand Down
2 changes: 1 addition & 1 deletion api/masteriqapp/models/Question.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@


class Question(models.Model):
text = models.CharField(max_length=255)
text = models.CharField(max_length=1024)
category = models.ForeignKey(Category, on_delete=models.CASCADE)
Loading