Force uniqueness on uuid
This commit is contained in:
parent
f8c29aa1d6
commit
1d1ae6fb3e
2 changed files with 20 additions and 1 deletions
|
@ -0,0 +1,19 @@
|
|||
# Generated by Django 3.0.3 on 2020-02-23 10:58
|
||||
|
||||
from django.db import migrations, models
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('opennebula', '0002_vm_uuid'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='vm',
|
||||
name='uuid',
|
||||
field=models.UUIDField(default=uuid.uuid4, editable=False, unique=True),
|
||||
),
|
||||
]
|
|
@ -6,7 +6,7 @@ from django.contrib.postgres.fields import JSONField
|
|||
|
||||
class VM(models.Model):
|
||||
vmid = models.IntegerField(primary_key=True)
|
||||
uuid = models.UUIDField(default=uuid.uuid4, editable=False)
|
||||
uuid = models.UUIDField(default=uuid.uuid4, editable=False, unique=True)
|
||||
owner = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)
|
||||
data = JSONField()
|
||||
|
||||
|
|
Loading…
Reference in a new issue