Skip to content

Commit

Permalink
users: Fix public_id being not really unique
Browse files Browse the repository at this point in the history
  • Loading branch information
rsebille committed Jun 12, 2024
1 parent 3160055 commit f2bfa4d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
33 changes: 33 additions & 0 deletions itou/users/migrations/0008_fix_user_public_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 5.0.6 on 2024-06-12 12:31

import uuid

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("users", "0007_fill_user_first_login"),
]

operations = [
migrations.RunSQL(
"""
UPDATE users_user
SET public_id = gen_random_uuid()
WHERE public_id = '09cbdf0f-cbba-4ef7-91b2-18eba95aacf2'""",
reverse_sql="""
UPDATE users_user
SET public_id = '09cbdf0f-cbba-4ef7-91b2-18eba95aacf2'
WHERE id <= 968115
""",
elidable=True,
),
migrations.AlterField(
model_name="user",
name="public_id",
field=models.UUIDField(
default=uuid.uuid4, unique=True, verbose_name="identifiant public opaque, pour les API"
),
),
]
1 change: 1 addition & 0 deletions itou/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ class User(AbstractUser, AddressMixin):
public_id = models.UUIDField(
verbose_name="identifiant public opaque, pour les API",
default=uuid.uuid4,
unique=True,
)

address_filled_at = models.DateTimeField(
Expand Down

0 comments on commit f2bfa4d

Please sign in to comment.