Skip to content

Commit

Permalink
fix: foreign key
Browse files Browse the repository at this point in the history
  • Loading branch information
st42597 authored and jimin9038 committed Mar 23, 2022
1 parent 6ee2690 commit 51f9849
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions backend/temperature/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.db import models
from utils.shortcuts import rand_str
from problem.models import Problem
from account.models import User


class JudgeStatus:
Expand Down Expand Up @@ -29,24 +30,23 @@ class ProblemScore:


class Temperature(models.Model):
user_id = models.IntegerField(unique=True)
user = models.ForeignKey(User, null=True, on_delete=models.CASCADE)
temperature = models.IntegerField(default=0)
date = models.DateField(auto_now_add=True)

class Meta:
db_table = "temperature"
unique_together = (("user_id", "date"),)
unique_together = (("user", "date"),)
ordering = ("-date",)


class SolvedProblem(models.Model):
id = models.TextField(default=rand_str, primary_key=True, db_index=True)
user_id = models.IntegerField(db_index=True)
_id = models.TextField(db_index=True, default=0)
user = models.ForeignKey(User, null=True, on_delete=models.CASCADE)
problem = models.ForeignKey(Problem, null=True, on_delete=models.CASCADE)
score = models.IntegerField()
solved_time = models.DateField(auto_now_add=True)

class Meta:
db_table = "solvedproblem"
unique_together = (("user_id", "_id"),)
unique_together = (("user", "problem"),)
ordering = ("-solved_time",)

0 comments on commit 51f9849

Please sign in to comment.