Skip to content

Commit

Permalink
refactor: add index to ECU user_fk field
Browse files Browse the repository at this point in the history
  • Loading branch information
jesperhodge committed Feb 25, 2025
1 parent ebf59e5 commit 1c046ab
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Generated by Django 4.2.16 on 2025-02-19 20:20

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('enterprise', '0229_enterprisecustomeruser_user_fk_and_more'),
]

operations = [
# Custom SQL to add indexes with zero-downtime options
migrations.RunSQL(
sql="""
ALTER TABLE enterprise_enterprisecustomeruser
ADD INDEX idx_enterprise_user_fk (user_fk),
ALGORITHM=INPLACE,
LOCK=NONE;
ALTER TABLE enterprise_historicalenterprisecustomeruser
ADD INDEX idx_historical_enterprise_user_fk (user_fk),
ALGORITHM=INPLACE,
LOCK=NONE;
""",
reverse_sql="""
ALTER TABLE enterprise_enterprisecustomeruser DROP INDEX idx_enterprise_user_fk;
ALTER TABLE enterprise_historicalenterprisecustomeruser DROP INDEX idx_historical_enterprise_user_fk;
"""
),
]
2 changes: 1 addition & 1 deletion enterprise/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ class EnterpriseCustomerUser(TimeStampedModel):
user_fk = models.IntegerField(
null=True,
blank=False,
db_index=False,
db_index=True,
)
active = models.BooleanField(default=True)
linked = models.BooleanField(default=True)
Expand Down

0 comments on commit 1c046ab

Please sign in to comment.