Add migration related to tag change
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
# Generated by Django 2.0.7 on 2018-11-17 19:28
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
i = 1
|
||||
def gen_uuid(apps, schema_editor):
|
||||
tag = apps.get_model('webapp', 'Tag')
|
||||
for row in tag.objects.all():
|
||||
global i
|
||||
row.id = i
|
||||
i += 1
|
||||
row.save()
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('webapp', '0047_auto_20180710_2110'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='tag',
|
||||
name='id',
|
||||
field=models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='tag',
|
||||
name='slug',
|
||||
field=models.SlugField(unique=True),
|
||||
),
|
||||
migrations.RunPython(gen_uuid, reverse_code=migrations.RunPython.noop),
|
||||
]
|
||||
Reference in New Issue
Block a user