Skip to content

Commit

Permalink
Add question and constraint to themes
Browse files Browse the repository at this point in the history
  • Loading branch information
nmenezes0 committed Mar 26, 2024
1 parent 11d3d34 commit c7d8cb0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 5.0.3 on 2024-03-26 21:27

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


class Migration(migrations.Migration):
dependencies = [
("consultations", "0001_initial"),
]

operations = [
migrations.AlterModelOptions(
name="theme",
options={},
),
migrations.AddField(
model_name="theme",
name="question",
field=models.ForeignKey(
null=True, on_delete=django.db.models.deletion.CASCADE, to="consultations.question"
),
),
migrations.AddConstraint(
model_name="theme",
constraint=models.UniqueConstraint(
fields=("summary", "label", "keywords", "question"), name="unique_up_to_question"
),
),
]
6 changes: 6 additions & 0 deletions consultation_analyser/consultations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ class Theme(UUIDPrimaryKeyModel, TimeStampedModel):
label = models.CharField(max_length=256, blank=True)
summary = models.TextField(blank=True)
keywords = models.JSONField(default=list)
question = models.ForeignKey(Question, on_delete=models.CASCADE, null=True)

class Meta:
constraints = [
models.UniqueConstraint(fields=["summary", "label", "keywords", "question"], name="unique_up_to_question"),
]


class Answer(UUIDPrimaryKeyModel, TimeStampedModel):
Expand Down
Binary file modified docs/erd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c7d8cb0

Please sign in to comment.