Skip to content

Commit

Permalink
chore: fix some db issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Topvennie committed Apr 3, 2024
1 parent 950cc22 commit 22544c4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 35 deletions.
14 changes: 4 additions & 10 deletions backend/api/fixtures/checks.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
- model: api.extracheck
pk: 1
fields:
project: 123456
run_script: 'scripts/run.sh'

- model: api.fileextension
pk: 1
fields:
extension: 'class'
extension: "class"
- model: api.fileextension
pk: 2
fields:
extension: 'png'
extension: "png"
- model: api.fileextension
pk: 3
fields:
extension: 'java'
extension: "java"
- model: api.fileextension
pk: 4
fields:
extension: 'py'
extension: "py"
21 changes: 4 additions & 17 deletions backend/api/fixtures/submissions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,23 @@
fields:
group: 1
submission_number: 1
submission_time: '2021-01-01T00:00:00Z'
submission_time: "2021-01-01T00:00:00Z"
structure_checks_passed: True
- model: api.submission
pk: 2
fields:
group: 1
submission_number: 2
submission_time: '2021-01-02T00:00:00Z'
submission_time: "2021-01-02T00:00:00Z"
structure_checks_passed: True

- model: api.submissionfile
pk: 1
fields:
submission: 1
file: 'submissions/1/1/1.txt'
file: "submissions/1/1/1.txt"
- model: api.submissionfile
pk: 2
fields:
submission: 2
file: 'submissions/1/2/1.txt'

- model: api.extrachecksresult
pk: 1
fields:
submission: 1
extra_check: 1
passed: False
- model: api.extrachecksresult
pk: 2
fields:
submission: 2
extra_check: 1
passed: True
file: "submissions/1/2/1.txt"
15 changes: 7 additions & 8 deletions backend/api/migrations/0008_add_extra_checks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from django.db import migrations, models

from api.models.checks import DockerImage
from api.models.submission import ErrorTemplates
from django.db import migrations, models
from ypovoli.settings import FILE_PATHS


Expand All @@ -13,7 +12,7 @@ class Migration(migrations.Migration):

operations = [
migrations.CreateModel(
name="docker_images",
name="dockerimage",
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=256, blank=False, null=False)),
Expand All @@ -22,7 +21,7 @@ class Migration(migrations.Migration):
]
),
migrations.CreateModel(
name="error_templates",
name="errortemplate",
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('message_key', models.CharField(max_length=256, blank=False, null=False)),
Expand All @@ -35,7 +34,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name="extracheck",
name="docker_image_id",
field=models.ForeignKey(DockerImage, on_delete=models.CASCADE, related_name="extra_checks"),
field=models.ForeignKey(to="api.dockerimage", on_delete=models.CASCADE, related_name="extra_checks"),
),
migrations.AddField(
model_name="extracheck",
Expand All @@ -53,13 +52,13 @@ class Migration(migrations.Migration):
field=models.BooleanField(default=True, blank=False, null=False)
),
migrations.AddField(
model_name="extracheckresult",
model_name="extrachecksresult",
name="error_message",
field=models.ForeignKey(ErrorTemplates, on_delete=models.CASCADE,
field=models.ForeignKey(to="api.errortemplate", on_delete=models.CASCADE,
related_name="extra_checks_results", blank=True, null=True)
),
migrations.AddField(
model_name="extracheckresult",
model_name="extrachecksresult",
name="log_file",
field=models.CharField(max_length=256, blank=False, null=True)
)
Expand Down
1 change: 1 addition & 0 deletions backend/api/models/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class DockerImage(models.Model):
"""

# ID should be generated automatically
id = models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')

# Name of the docker image
name = models.CharField(
Expand Down

0 comments on commit 22544c4

Please sign in to comment.