Skip to content

Commit 342f984

Browse files
committed
feat: update UUID generation to use uuid.uuid7 and add uuid-utils dependency
1 parent 04642eb commit 342f984

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

apps/users/migrations/0001_initial.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Generated by Django 5.2 on 2025-04-14 02:22
22

3-
import uuid
3+
import uuid_utils.compat
44
from django.db import migrations, models
55

66
from common.constants.permission_constants import RoleConstants
@@ -26,7 +26,7 @@ class Migration(migrations.Migration):
2626
migrations.CreateModel(
2727
name='User',
2828
fields=[
29-
('id', models.UUIDField(default=uuid.uuid1, editable=False, primary_key=True, serialize=False,
29+
('id', models.UUIDField(default=uuid_utils.compat.uuid7, editable=False, primary_key=True, serialize=False,
3030
verbose_name='主键id')),
3131
('email', models.EmailField(blank=True, max_length=254, null=True, unique=True, verbose_name='邮箱')),
3232
('phone', models.CharField(default='', max_length=20, verbose_name='电话')),

apps/users/models/user.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
@date:2025/4/14 10:20
77
@desc:
88
"""
9-
import uuid
9+
import uuid_utils.compat as uuid
1010

1111
from django.db import models
1212

1313
from common.utils.common import password_encrypt
1414

1515

1616
class User(models.Model):
17-
id = models.UUIDField(primary_key=True, max_length=128, default=uuid.uuid1, editable=False, verbose_name="主键id")
17+
id = models.UUIDField(primary_key=True, max_length=128, default=uuid.uuid7, editable=False, verbose_name="主键id")
1818
email = models.EmailField(unique=True, null=True, blank=True, verbose_name="邮箱")
1919
phone = models.CharField(max_length=20, verbose_name="电话", default="")
2020
nick_name = models.CharField(max_length=150, verbose_name="昵称", default="")

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ django-redis = "5.4.0"
1313
django-db-connection-pool = "1.2.5"
1414
psycopg = {extras = ["binary"], version = "3.2.6"}
1515
python-dotenv = "1.1.0"
16+
uuid-utils = "0.10.0"
1617

1718
[build-system]
1819
requires = ["poetry-core"]

0 commit comments

Comments
 (0)