umap/umap/migrations/0018_datalayer_uuid.py

35 lines
1,023 B
Python
Raw Normal View History

# Generated by Django 4.2.8 on 2024-02-19 17:40
import uuid
from django.db import migrations, models
def gen_uuid(apps, schema_editor):
DataLayer = apps.get_model("umap", "DataLayer")
for row in DataLayer.objects.all():
row.uuid = uuid.uuid4()
row.save(update_fields=["uuid"])
class Migration(migrations.Migration):
dependencies = [
("umap", "0017_migrate_to_openstreetmap_oauth2"),
]
operations = [
migrations.AddField(
model_name="datalayer",
name="uuid",
field=models.UUIDField(default=uuid.uuid4, editable=False, null=True),
),
migrations.RunPython(gen_uuid, reverse_code=migrations.RunPython.noop),
migrations.AlterField("datalayer", name="id", field=models.CharField(max_length=100)),
migrations.AlterField(
model_name="datalayer",
name="uuid",
field=models.UUIDField(default=uuid.uuid4, editable=False, unique=True, primary_key=True),
),
]