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

Add explicit on_delete to foreign key and one to one relationships #188

Merged
merged 1 commit into from
Jul 6, 2017
Merged
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
12 changes: 9 additions & 3 deletions silk/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ def save(self, *args, **kwargs):

class Response(models.Model):
id = CharField(max_length=36, default=uuid4, primary_key=True)
request = OneToOneField(Request, related_name='response', db_index=True)
request = OneToOneField(
Request, related_name='response', db_index=True,
on_delete=models.CASCADE,
)
status_code = IntegerField()
raw_body = TextField(blank=True, default='')
body = TextField(blank=True, default='')
Expand Down Expand Up @@ -186,7 +189,7 @@ class SQLQuery(models.Model):
time_taken = FloatField(blank=True, null=True)
request = ForeignKey(
Request, related_name='queries', null=True,
blank=True, db_index=True
blank=True, db_index=True, on_delete=models.CASCADE,
)
traceback = TextField()
objects = SQLQueryManager()
Expand Down Expand Up @@ -256,7 +259,10 @@ class BaseProfile(models.Model):
name = CharField(max_length=300, blank=True, default='')
start_time = DateTimeField(default=timezone.now)
end_time = DateTimeField(null=True, blank=True)
request = ForeignKey(Request, null=True, blank=True, db_index=True)
request = ForeignKey(
Request, null=True, blank=True, db_index=True,
on_delete=models.CASCADE,
)
time_taken = FloatField(blank=True, null=True)

class Meta:
Expand Down