Skip to content

Commit

Permalink
change: bring back indexes on SET_NULL foreign keys
Browse files Browse the repository at this point in the history
While these are not used during normal operations, they are necessary
for UPDATE queries when deleting the content. Otherwise they end up as
full table scans.
  • Loading branch information
nijel committed Oct 11, 2023
1 parent d0bfe7e commit 49a34b1
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 7 deletions.
1 change: 1 addition & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Not yet released.
* Strings which can not be saved to a file no longer block other strings to be written.
* Fixed some API URLs for categorized components.
* Show plural form examples more prominently.
* Faster components removal.

**Bug fixes**

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright © Michal Čihař <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-or-later

# Generated by Django 4.2.5 on 2023-10-11 12:49

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


class Migration(migrations.Migration):
dependencies = [
("screenshots", "0001_squashed_weblate_5"),
("trans", "0004_alter_change_action"),
]

operations = [
migrations.AlterField(
model_name="change",
name="alert",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="trans.alert",
),
),
migrations.AlterField(
model_name="change",
name="announcement",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="trans.announcement",
),
),
migrations.AlterField(
model_name="change",
name="comment",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="trans.comment",
),
),
migrations.AlterField(
model_name="change",
name="screenshot",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="screenshots.screenshot",
),
),
migrations.AlterField(
model_name="change",
name="suggestion",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="trans.suggestion",
),
),
]
11 changes: 4 additions & 7 deletions weblate/trans/models/change.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,23 +534,20 @@ class Change(models.Model, UserDisplayMixin):
"Translation", null=True, on_delete=models.deletion.CASCADE, db_index=False
)
comment = models.ForeignKey(
"Comment", null=True, on_delete=models.deletion.SET_NULL, db_index=False
"Comment", null=True, on_delete=models.deletion.SET_NULL
)
suggestion = models.ForeignKey(
"Suggestion", null=True, on_delete=models.deletion.SET_NULL, db_index=False
"Suggestion", null=True, on_delete=models.deletion.SET_NULL
)
announcement = models.ForeignKey(
"Announcement", null=True, on_delete=models.deletion.SET_NULL, db_index=False
"Announcement", null=True, on_delete=models.deletion.SET_NULL
)
screenshot = models.ForeignKey(
"screenshots.Screenshot",
null=True,
on_delete=models.deletion.SET_NULL,
db_index=False,
)
alert = models.ForeignKey(
"Alert", null=True, on_delete=models.deletion.SET_NULL, db_index=False
)
alert = models.ForeignKey("Alert", null=True, on_delete=models.deletion.SET_NULL)
user = models.ForeignKey(
settings.AUTH_USER_MODEL, null=True, on_delete=models.deletion.CASCADE
)
Expand Down

0 comments on commit 49a34b1

Please sign in to comment.