membershipworks: Remove DB constraints for FKs to Members table

MariaDB doesn't support partitions on tables with FKs, and performance
of the Members table has become unusable due to size caused by system
versioning
This commit is contained in:
Adam Goldsmith 2023-12-26 12:47:06 -05:00
parent 9a0d6012b9
commit d44903b561
2 changed files with 40 additions and 1 deletions

View File

@ -0,0 +1,36 @@
# Generated by Django 5.0 on 2023-12-26 17:46
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("membershipworks", "0003_alter_transaction_sid"),
]
operations = [
migrations.AlterField(
model_name="memberflag",
name="member",
field=models.ForeignKey(
db_column="uid",
db_constraint=False,
on_delete=django.db.models.deletion.PROTECT,
to="membershipworks.member",
),
),
migrations.AlterField(
model_name="transaction",
name="member",
field=models.ForeignKey(
blank=True,
db_column="uid",
db_constraint=False,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="transactions",
to="membershipworks.member",
),
),
]

View File

@ -259,7 +259,9 @@ class Member(BaseModel):
class MemberFlag(BaseModel): class MemberFlag(BaseModel):
member = models.ForeignKey(Member, on_delete=models.PROTECT, db_column="uid") member = models.ForeignKey(
Member, on_delete=models.PROTECT, db_column="uid", db_constraint=False
)
flag = models.ForeignKey(Flag, on_delete=models.PROTECT) flag = models.ForeignKey(Flag, on_delete=models.PROTECT)
def __str__(self): def __str__(self):
@ -280,6 +282,7 @@ class Transaction(BaseModel):
Member, Member,
on_delete=models.PROTECT, on_delete=models.PROTECT,
db_column="uid", db_column="uid",
db_constraint=False,
related_name="transactions", related_name="transactions",
null=True, null=True,
blank=True, blank=True,