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

[chores] Updated index_together constraint #408

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion openwisp_users/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ class AbstractUser(BaseUser):

class Meta(BaseUser.Meta):
abstract = True
index_together = ('id', 'email')
indexes = [
models.Index(name='user_id_email_idx', fields=['id', 'email']),
]

@staticmethod
def _get_pk(obj):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.16 on 2024-09-04 12:00

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("openwisp_users", "0020_populate_password_updated_field"),
]

operations = [
migrations.RenameIndex(
model_name="user",
new_name="user_id_email_idx",
old_fields=("id", "email"),
),
]
5 changes: 4 additions & 1 deletion tests/openwisp2/sample_users/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ class Migration(migrations.Migration):
'verbose_name': 'user',
'verbose_name_plural': 'users',
'abstract': False,
'index_together': {('id', 'email')},
},
managers=[
('objects', openwisp_users.base.models.UserManager()),
Expand Down Expand Up @@ -500,4 +499,8 @@ class Migration(migrations.Migration):
to=settings.AUTH_USER_MODEL,
),
),
migrations.AddIndex(
model_name="user",
index=models.Index(fields=["id", "email"], name="user_id_email_idx"),
),
]
Loading