Marta Miranda

Closed feature/#45_agregar_uuid_a_los_edictos

# Generated by Django 4.1.9 on 2023-09-08 11:10
from django.db import migrations, models
import uuid
class Migration(migrations.Migration):
dependencies = [
('edicto', '0010_alter_edicto_fecha_creacion'),
]
operations = [
migrations.AddField(
model_name='edicto',
name='uuid',
field=models.UUIDField(default=uuid.uuid4),
),
]
... ...
# Generated by Django 4.1.9 on 2023-09-08 11:19
from django.db import migrations, models
import uuid
def migrar_datos_uuid(apps, schema):
Edictos = apps.get_model('edicto', 'Edicto')
for edicto in Edictos.objects.all():
edicto.uuid = uuid.uuid4()
edicto.save()
class Migration(migrations.Migration):
dependencies = [
('edicto', '0011_edicto_uuid'),
]
operations = [
migrations.RunPython(migrar_datos_uuid, reverse_code=migrations.RunPython.noop),
migrations.AlterField(
model_name='edicto',
name='uuid',
field=models.UUIDField(default=uuid.uuid4, editable=False, unique=True),
),
]
... ...
from django.db import models
from uuid import uuid4
from .constants import STATUS_CHOICE, MONEDA
from usuario.models import Usuario
... ... @@ -24,6 +25,7 @@ class Precio (models.Model):
class Edicto(models.Model):
uuid = models.UUIDField(unique=True, editable=False, default=uuid4)
usuario = models.ForeignKey(Usuario, on_delete=models.CASCADE, verbose_name='Usuario')
cuerpo_edicto = models.TextField(blank=False, null=False)
archivo = models.FileField(upload_to="uploads/%Y/%m/%d/", null=False, blank=False)
... ...