Showing
4 changed files
with
70 additions
and
0 deletions
1 | +# Generated by Django 4.1.9 on 2023-09-25 11:23 | ||
2 | + | ||
3 | +from django.db import migrations, models | ||
4 | + | ||
5 | + | ||
6 | +class Migration(migrations.Migration): | ||
7 | + | ||
8 | + dependencies = [ | ||
9 | + ('edicto', '0001_initial'), | ||
10 | + ] | ||
11 | + | ||
12 | + operations = [ | ||
13 | + migrations.RemoveField( | ||
14 | + model_name='edicto', | ||
15 | + name='uuid', | ||
16 | + ), | ||
17 | + migrations.AddField( | ||
18 | + model_name='edicto', | ||
19 | + name='id', | ||
20 | + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), | ||
21 | + preserve_default=False, | ||
22 | + ), | ||
23 | + ] |
1 | +# Generated by Django 4.1.9 on 2023-09-25 11:29 | ||
2 | + | ||
3 | +from django.db import migrations, models | ||
4 | +import uuid | ||
5 | + | ||
6 | + | ||
7 | +class Migration(migrations.Migration): | ||
8 | + | ||
9 | + dependencies = [ | ||
10 | + ('edicto', '0002_remove_edicto_uuid_edicto_id'), | ||
11 | + ] | ||
12 | + | ||
13 | + operations = [ | ||
14 | + migrations.AddField( | ||
15 | + model_name='edicto', | ||
16 | + name='uuid', | ||
17 | + field=models.UUIDField(default=uuid.uuid4, editable=False, null=True, unique=True), | ||
18 | + ), | ||
19 | + ] |
1 | +# Generated by Django 4.1.9 on 2023-09-25 11:35 | ||
2 | + | ||
3 | +from django.db import migrations, models | ||
4 | +import uuid | ||
5 | + | ||
6 | + | ||
7 | +def migrar_datos_uuid(apps, schema): | ||
8 | + Edictos = apps.get_model('edicto', 'Edicto') | ||
9 | + for edicto in Edictos.objects.all(): | ||
10 | + edicto.uuid = uuid.uuid4() | ||
11 | + edicto.save() | ||
12 | + | ||
13 | + | ||
14 | +class Migration(migrations.Migration): | ||
15 | + | ||
16 | + dependencies = [ | ||
17 | + ('edicto', '0003_edicto_uuid'), | ||
18 | + ] | ||
19 | + | ||
20 | + operations = [ | ||
21 | + migrations.RunPython(migrar_datos_uuid, reverse_code=migrations.RunPython.noop), | ||
22 | + migrations.AlterField( | ||
23 | + model_name='edicto', | ||
24 | + name='uuid', | ||
25 | + field=models.UUIDField(default=uuid.uuid4, editable=False, unique=True), | ||
26 | + ), | ||
27 | + ] |
@@ -15,6 +15,7 @@ class EdictoSerializer(serializers.ModelSerializer): | @@ -15,6 +15,7 @@ class EdictoSerializer(serializers.ModelSerializer): | ||
15 | class Meta: | 15 | class Meta: |
16 | model = Edicto | 16 | model = Edicto |
17 | fields = ( | 17 | fields = ( |
18 | + 'uuid', | ||
18 | 'creado_por', | 19 | 'creado_por', |
19 | 'modificado_por', | 20 | 'modificado_por', |
20 | 'estado', | 21 | 'estado', |
-
Please register or login to post a comment