From 1d1ae6fb3e113583f3926bd4f54306979497429f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 23 Feb 2020 11:59:09 +0100 Subject: [PATCH] Force uniqueness on uuid --- .../migrations/0003_auto_20200223_1058.py | 19 +++++++++++++++++++ nicohack202002/uncloud/opennebula/models.py | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 nicohack202002/uncloud/opennebula/migrations/0003_auto_20200223_1058.py diff --git a/nicohack202002/uncloud/opennebula/migrations/0003_auto_20200223_1058.py b/nicohack202002/uncloud/opennebula/migrations/0003_auto_20200223_1058.py new file mode 100644 index 0000000..d2173da --- /dev/null +++ b/nicohack202002/uncloud/opennebula/migrations/0003_auto_20200223_1058.py @@ -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), + ), + ] diff --git a/nicohack202002/uncloud/opennebula/models.py b/nicohack202002/uncloud/opennebula/models.py index 0f93b78..ff0e49c 100644 --- a/nicohack202002/uncloud/opennebula/models.py +++ b/nicohack202002/uncloud/opennebula/models.py @@ -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()